Reputation: 103
I am trying to display a data based on xml in jqGrid. I use jqGrid in many places in my grid and it works with my earlier xml data.
The only difference is in xml. Current xml contains different tags.
$("#uxData").jqGrid({
url: ServiceUrl,
datatype: 'xml',
mtype: 'GET',
colNames: ['CardCode'],
colModel: [
{ name: 'CardCode', index: 'CardCode', sortable: true, align: "left", width: 100, search: true }
],
loadError: function (xhr, status, error) {
$(this).HideBusy();
alert(xhr.responseText);
},
loadComplete: function (data) {
$("#Window").dialog('open');
$(this).HideBusy();
debugger;
},
serializeGridData: function (postData) {
if (postData.searchField === undefined) postData.searchField = null;
if (postData.searchString === undefined) postData.searchString = null;
if (postData.searchOper === undefined) postData.searchOper = null;
if (postData.filters === undefined) postData.filters = null;
return (postData);
},
ondblClickRow: function (rowid, iRow, iCol, e) {
//debugger;
//var SelectedRow = $("#ListOfBP1").jqGrid('getRowData', rowid, 'selrow');
//$("#uxCardCode").val(SelectedRow.CardCode);
//$("#Text4").val(SelectedRow.CardName);
$("#Window").dialog('close');
},
xmlReader: {
repeatitems: false,
total: "Root>total",
page: "Root>page",
records: "Root>records",
rows: "Root>rows>DocumentElement>data"
},
pager: 'rptParamPager',
rowNum: 5,
viewrecords: true,
gridview: true,
rownumbers: true,
height: 440,
width: 900
}).trigger('reloadGrid');
<Root>
<total>161</total>
<page>1</page>
<records>805</records>
<rows>
<DocumentElement>
<data>
<CardCode>a</CardCode>
<CardName>aasas as</CardName>
<CardType>C</CardType>
<Balance>0.000000</Balance>
</data>
<data>
<CardCode>A0001</CardCode>
<CardName>Manish Chourasia</CardName>
<CardType>C</CardType>
<Balance>100000.000000</Balance>
</data>
<data>
<CardCode>A0002</CardCode>
<CardName>Manish Chourasia</CardName>
<CardType>C</CardType>
<Balance>568368.000000</Balance>
</data>
<data>
<CardCode>A0003</CardCode>
<CardName>Vivek</CardName>
<CardType>C</CardType>
<Balance>0.000000</Balance>
</data>
<data>
<CardCode>A00034</CardCode>
<CardName>TUSHAR NATHWANI</CardName>
<CardType>C</CardType>
<Balance>0.000000</Balance>
</data>
</DocumentElement>
</rows>
</Root>
I tried a lot to tweak xmlReader but does not work. I am completely confused with the behavior of xmlReader.
Can anybody help me?
Upvotes: 0
Views: 89
Reputation: 221997
You should fix the xmlReader
to the following:
xmlReader: {
repeatitems: false,
total: "Root>total",
page: "Root>page",
records: "Root>records",
root: "Root>rows>DocumentElement",
row: "data"
}
Upvotes: 1