jqrid从网格数据生成xml [英] jqrid generate xml from grid data

查看:77
本文介绍了jqrid从网格数据生成xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试几个小时,以便根据网格数据生成xml字符串,此时列名称将为标记名称,而网格内容将位于其中. 我的网格是使用xmlReader初始化的. 我尝试使用:

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 = {行:grid.jqGrid('getGridParam','data')}; var xmldata = xmlJsonClass.json2xml(dataFromGrid,'\ t'); alert(xmldata);

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

但是它对我不起作用. 如何才能做到这一点?如果可能的话,最好不要使用json. 谢谢谢谢.

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.

这是我的代码:我正在使用数据类型xml.

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.

更新:重要的是,在问题中包括jqGrid的定义.仅在本地数据的情况下填充data参数(例如,如果您使用datatype:"local"datatype:"xmlstring"或使用loadonce:true附加参数,则在第一次加载数据后将datatype更改为datatype:"local" .因此,如果我的旧答案不能帮助您,则应在问题中附加其他信息.

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.

这篇关于jqrid从网格数据生成xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆