0
jQuery("#assignfixtureTable").jqGrid({
url : successdata,
datatype: "xml",
height: 250,
我想指定XML數據的jqGrid,我不想調用的URL,並將其分配給它。如何分配XML數據的jqGrid
jQuery("#assignfixtureTable").jqGrid({
url : successdata,
datatype: "xml",
height: 250,
我想指定XML數據的jqGrid,我不想調用的URL,並將其分配給它。如何分配XML數據的jqGrid
您可以使用xmlstring
的數據類型,並使用datastr
選項傳遞xml數據。以下是來自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>
謝謝。我的問題已解決。現在的問題是我想進行ajax調用並將xml對象作爲帖子傳遞並以json格式接收響應 – user1671219