日期:2014-05-16 浏览次数:20662 次
<html >
<head>
<link href="css/ui.jqgrid.css" rel="stylesheet" type="text/css" />
<link href="css/jquery-ui-1.8.18.custom.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js" type="text/javascript"> </script>
<script src="js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"> </script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"> </script>
</head>
<body>
<table id="list1"></table>
<div id="pager1"></div>
<script type="text/javascript">
$(function(){
jQuery("#list1").jqGrid({
datatype: "xml",
url:'test.xml',
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}
],
xmlReader: {
root: "rows",
row: "row",
page: "page",
total: "total",
cell: "cell",
id: "[id]",
repeatitems: false ,
userdata: "userdata"
},
rowNum:10,
autowidth: true,
rowList:[10,20,30],
pager: jQuery('#pager1'),
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"XML Example"
});
});
</script>
</body>
</html>
<rows>
<page>1</page>
<total>2</total>
<userdata name="totalinvoice">240.00</userdata>
<userdata name="tax">40.00</userdata>
<row id='1'>
<cell>111</cell>
<cell>222</cell>&nb