Reputation: 3050
I'm trying to load data (in xml form) into my jqgrid from a jsp page, but I can't understand why I'm not seeing the data inside the grid. I tried everything, but it's still not working.
This is my html page:
<script type="text/javascript">
$(document).ready(function()
{
jQuery("#list1").jqGrid({
url:'server.jsp',
datatype: "xml",
mtype: 'GET' ,
colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
colModel:[
{name:'id',index:'id', width:75},
{name:'invdate',index:'invdate', width:90},
{name:'name',index:'name', width:100},
{name:'amount',index:'amount', width:80, align:"right"},
{name:'tax',index:'tax', width:80, align:"right"},
{name:'total',index:'total', width:80,align:"right"},
{name:'note',index:'note', width:150, sortable:false}
],
rowNum:10,
autowidth: true,
rowList:[10,20,30],
pager: jQuery('#pager1'),
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"XML Example"
}).navGrid('#pager1',{edit:false,add:false,del:false});
});
<table id="list1"></table>
<div id="pager1"></div>
This is my jsp page:
<%
response.setContentType("text/xml;charset=utf-8");
%>
<?xml version='1.0' encoding = 'utf-8'?>
<rows>
<page>1</page>
<total>5</total>
<records>5</records>
<row id='1'>
<cell>1</cell>
<cell>2</cell>
<cell><![CDATA[eeeeeee]]></cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell><![CDATA[eeeeeee]]></cell>
</row>
<row id='2'>
<cell>1</cell>
<cell>2</cell>
<cell><![CDATA[eeeeeee]]></cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell><![CDATA[eeeeeee]]></cell>
</row>
<row id='3'>
<cell>1</cell>
<cell>2</cell>
<cell><![CDATA[eeeeeee]]></cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell><![CDATA[eeeeeee]]></cell>
</row>
<row id='4'>
<cell>1</cell>
<cell>2</cell>
<cell><![CDATA[eeeeeee]]></cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell><![CDATA[eeeeeee]]></cell>
</row>
<row id='5'>
<cell>1</cell>
<cell>2</cell>
<cell><![CDATA[eeeeeee]]></cell>
<cell>3</cell>
<cell>4</cell>
<cell>5</cell>
<cell><![CDATA[eeeeeee]]></cell>
</row>
</rows>
What am I doing wrong?
Upvotes: 0
Views: 1288
Reputation: 79
Add autoencode: true, in your JQgrid
jQuery("#list1").jqGrid({
url:'server.jsp',
datatype: "xml",
autoencode: true,
mtype: 'GET' ,
Upvotes: 0
Reputation: 80
I am having a similar issue using JSON data, jquery 1.5, and jquery.validate.min.js.
Version 1.8 of jquery.validate.min.js resolves this issue!
Upvotes: 0
Reputation: 221997
You should probably search for the reason of the problem somewhere else.
How you can see here the code which you posted do display the data. One remark only the value of total
should be the number of pages and not the number of records, but the XML data looks more as a dummy data.
Upvotes: 1