如何将xml数据分配给jqgrid [英] How to assign xml data to jqgrid
本文介绍了如何将xml数据分配给jqgrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery("#assignfixtureTable").jqGrid({
url : successdata,
datatype: "xml",
height: 250,
我想将xml数据分配给jqgrid,我不想调用该URL并将其分配给它.
I want to assign the xml data to jqgrid , I dont want to call the url and assign it to it.
推荐答案
您可以使用xmlstring
的数据类型,并使用datastr
选项传递xml数据.这是文档页面中的示例:>
You can use a datatype of xmlstring
and pass your xml data using the datastr
option. Here is an example from the documentation page:
<script>
var mystr =
"<?xml version='1.0' encoding='utf-8'?>
<invoices>
<rows>
<row>
<cell>data1</cell>
<cell>data2</cell>
<cell>data3</cell>
<cell>data4</cell>
<cell>data5</cell>
<cell>data6</cell>
</row>
</rows>
</invoices>";
jQuery(document).ready(function(){
jQuery("#list").jqGrid({
datatype: 'xmlstring',
datastr : mystr,
colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],
colModel :[
{name:'invid', index:'invid', width:55, sorttype:'int'},
{name:'invdate', index:'invdate', width:90, sorttype:'date', datefmt:'Y-m-d'},
{name:'amount', index:'amount', width:80, align:'right', sorttype:'float'},
{name:'tax', index:'tax', width:80, align:'right', sorttype:'float'},
{name:'total', index:'total', width:80, align:'right', sorttype:'float'},
{name:'note', index:'note', width:150, sortable:false} ],
pager: '#pager',
rowNum:10,
viewrecords: true,
caption: 'My first grid'
});
});
</script>
这篇关于如何将xml数据分配给jqgrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文