0

I'm trying for a few hours now to generate an xml string from my grid's data , when the columns names will be the tag names and the content of the grid will be inside of them. my grid is initialized with xmlReader. I tried using:

var dataFromGrid = {row: grid.jqGrid('getGridParam', 'data') }; var xmldata = xmlJsonClass.json2xml (dataFromGrid, '\t'); alert(xmldata);

but it did not work for me. how can this be done? it will be better not using json, if it's possible. Thank's In advance.

Update:

This is my code: I'm using datatype xml.

Query("#signatory2_payment").jqGrid({
                url:'loadgrid.jsp?type=3',
                datatype: "xml",
                direction:"rtl",
                height: '100%',
                width: '100%',
                colNames:['group_order','claim','beneficiary_description','insurance_code_description'],
                colModel:[
                    {name:'group_order',xmlmap:'group_order', width:80, align:"right",sorttype:"int"},
                    {name:'claim',xmlmap:'claim', width:70, align:"right",sorttype:"int"},
                    {name:'beneficiary_description',xmlmap:'beneficiary_description', width:120, align:"right",sorttype:"string"},
                    {name:'insurance_code_description',xmlmap:'insurance_code_description', width:120, align:"right",sorttype:"string"}},
                ],
                xmlReader: {
                      root:"payments",
                      row:"payment",
                      page:"payments>page",
                      total:"payments>total",
                      records:"payments>records",
                      repeatitems:false
                  },
                multiselect: false,
                autowidth: true,
                forceFit: false,
                shrinkToFit: false,
                caption: " xxxxxx "
            });

If i understood you correctly it will work only on local data? What is the solution for data that is not local? Thank's again.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
nnnn
  • 13
  • 1
  • 4
  • If you fill the grid **once** and use no server side data paging or server side searching, than probably you should just add `loadonce:true` to your grid. It could solve your problem. You can add additionally parameters like `rowNum:10` and `rowList:[10,20,100,1000]`, which gives you **local** data paging, sorting and after small modifications also local searching/filtering. – Oleg Jan 24 '11 at 15:06

1 Answers1

0

Look at the answer. You will find here a working demo which do what you need.

UPDATED: It is important, that you include definition of jqGrid in your question. The data parameter will be filled only in case of local data (for example if you use datatype:"local", datatype:"xmlstring" or use loadonce:true additional parameter which changes the datatype to datatype:"local" after the first load of data. So if my old answer will help you not you should append your question with additional informations.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798