正尝试使用某些博客中提供的示例将jQuery Grid添加到我的应用程序(C#和Asp.net)中,能够使用由Webservice发送的Json数据。 现在已经尝试为网格添加分页并遭到攻击.Script是这样的。为JqGrid添加分页
<script type="text/javascript">
$(function() {
$("#table").jqGrid({
datatype: function (pdata) { getData(pdata); },
height: 250,
colNames: ['ID', 'First Name', 'Last Name'],
colModel: [
{ name: 'ID', width: 60, sortable: false },
{ name: 'FirstName', width: 200, sortable: false },
{ name: 'LastName', width: 200, sortable: false }
],
imgpath: '<%= ResolveClientUrl("styles/redmon/images") %>',
pager: jQuery('#pager'),
rowNum: 2,
rowList: [2, 5, 10, 50, 100, 200, 500, 1000],
height: "100%",
viewrecords: true,
scrollOffset: 0,
caption: 'Sample'
});
});
function getData(pData) {
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: '<%= ResolveClientUrl("~/WebService.asmx/GetListOfPersons") %>',
data: '{}',
dataType: "json",
success: function (data, textStatus) {
if (textStatus == "success")
ReceivedClientData(JSON.parse(getMain(data)).rows);
},
error: function (data, textStatus) {
alert('An error has occured retrieving data!');
}
});
}
function ReceivedClientData(data) {
var thegrid = $("#table");
thegrid.clearGridData();
for (var i = 0; i < data.length; i++)
thegrid.addRowData(i + 1, data[i]);
}
function getMain(dObj) {
if (dObj.hasOwnProperty('d'))
return dObj.d;
else
return dObj;
}
</script>
... HTML块
<table id="table" cellpadding="0" cellspacing="0">
</table>
<div id="pager" class="scroll" style="text-align:center;"></div>
显示寻呼机股利和附但是,这不是我的工作我失去了一些东西?
感谢 塞缪尔
嗨,奥列格感谢您的快速响应。是使用3.5版本。 1来解释两个版本之间的差异。另外,您能否提供服务器端分页的示例链接? –
@Samuel:无论如何,我严格推荐你[下载](http://www.trirand.com/blog/?page_id=6)jqGrid的最新版本。分页的实施取决于您在服务器端使用的技术。你是否使用实体框架,例如LINQ to SQL或'SqlDataReader'? – Oleg
Oleg,我使用SqlDataReader。已经下载了4.2版本,并试图获得一些逻辑来实现服务器端分页,正如你通知大数据集。 –