开发者

jqrid generate xml from grid data

开发者 https://www.devze.com 2023-02-06 22:21 出处:网络
I\'m trying for a few hours now to generate an xml stringfrom my grid\'s data , when the columns names will be the tag names and the content of the grid will be inside of them.

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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消