jquery easyui分页问题最近学习jquery easyui,使用datagrid以及分页,第一页数据显示出来了,但是总的页数不
jquery easyui分页问题
最近学习jquery easyui,使用datagrid以及分页,第一页数据显示出来了,但是总的页数不对,因此也不能点击下一页。总的记录数29条,10条一页,应该显示3页,但是只显示了第一页10条数据。选择每页20条,能看到20条。
前台代码应该没问题,从网上复制的。我刚觉应该是
$('#tt').datagrid({
width:810,
height:400,
idField: 'EmployeeID',
url: 'EmployeHandler.ashx',
singleSelect:true,
columns:[[
{ field: 'EmployeeID', title: '编号', width: 30 },
{ field: 'LastName', title: '姓氏', width: 60 },
{ field: 'FirstName', title: '名字', width: 60 },
{ field: 'City', title: '城市', width: 60 },
{ field: 'Country', title: '国家', width: 60 }
]],
pagination:true
});
url: 'EmployeHandler.ashx',这里面处理json转换的时候出的问题。
是不是返回的json数据中应该有数据集的总行数的信息呢?
返回的json是
[{"EmployeeID":1,"LastName":"Davolio","FirstName":"Nancy","City":"Seattle","Country":"USA"},{"EmployeeID":2,"LastName":"Fuller","FirstName":"Andrew","City":"Tacoma","Country":"USA"},{"EmployeeID":3,"LastName":"Leverling","FirstName":"Janet","City":"Kirkland","Country":"USA"},{"EmployeeID":4,"LastName":"Peacock","FirstName":"Margaret","City":"Redmond","Country":"USA"},{"EmployeeID":5,"LastName":"Buchanan","FirstName":"Steven","City":"London","Country":"UK"},{"EmployeeID":6,"LastName":"Suyama","FirstName":"Michael","City":"London","Country":"UK"},{"EmployeeID":7,"LastName":"King","FirstName":"Robert","City":"London","Country":"UK"},{"EmployeeID":8,"LastName":"Callahan","FirstName":"Laura","City":"Seattle","Country":"USA"},{"EmployeeID":9,"LastName":"Dodsworth","FirstName":"Anne","City":"London","Country":"UK"},{"EmployeeID":10,"LastName":"Smith20","FirstName":"Bill20","City":"London","Country":"UK"}]
有哪位大神指点一下是哪里除了问题,搞了好久没有弄好,网上也没见json具体格式,都是封装的取数,直接一个dataset2json,郁闷啊!!!
easyui pagination json
[解决办法]是的,要加入总记录数,如1000条:
{"total":1000,"rows":
[{"EmployeeID":1,"LastName":"Davolio","FirstName":"Nancy","City":"Seattle","Country":"USA"},{"EmployeeID":2,"LastName":"Fuller","FirstName":"Andrew","City":"Tacoma","Country":"USA"},{"EmployeeID":3,"LastName":"Leverling","FirstName":"Janet","City":"Kirkland","Country":"USA"},{"EmployeeID":4,"LastName":"Peacock","FirstName":"Margaret","City":"Redmond","Country":"USA"},{"EmployeeID":5,"LastName":"Buchanan","FirstName":"Steven","City":"London","Country":"UK"},{"EmployeeID":6,"LastName":"Suyama","FirstName":"Michael","City":"London","Country":"UK"},{"EmployeeID":7,"LastName":"King","FirstName":"Robert","City":"London","Country":"UK"},{"EmployeeID":8,"LastName":"Callahan","FirstName":"Laura","City":"Seattle","Country":"USA"},{"EmployeeID":9,"LastName":"Dodsworth","FirstName":"Anne","City":"London","Country":"UK"},{"EmployeeID":10,"LastName":"Smith20","FirstName":"Bill20","City":"London","Country":"UK"}]
}