日期:2014-05-16  浏览次数:20322 次

jquery的DataTable插件有熟悉的吗?我想做服务器端分页
小数据量DataTable插件确实方便,但是我想知道如何做服务器端分页
比如ashx返回了10条数据,只是每页显示10条,DataTable如何正确显示页码
又如何通过页码的点击,获取到分页信息(比如我点了3,应该进第3页,如何获取到用户点的是几)
还有←→那种简易翻页又是怎么获取到页码的
有代码的感激不尽

------解决方案--------------------
$oTable = $('#example').dataTable( { 
"bProcessing": true, 
"bAutoWidth": false,
"sAjaxSource": baseUrl+"infoManage/findByCondiInfo.do",
"bServerSide":true, //服务器端必须设置为true
"sAjaxDataProp":"msgJson.list",
"fnServerData": function (sSource, aoData, fnCallback ) {
aoData.push({"name": "cateId", "value": $(currentNode).attr("id")});
aoData.push({"name": "publishRuleId", "value": $("#publishRule").val()}); 
aoData.push({"name": "keywords", "value": $("#keywords").val()});
aoData.push({"name": "startDate", "value": $("#startDate").val()});
aoData.push({"name": "endDate", "value": $("#endDate").val()});
aoData.push({"name": "state", "value": $("#state").val()}); 
aoData.push({"name": "infoType", "value": $("#infoType").val()}); 
aoData.push({"name": "sourceType", "value": $("#sourceType").val()}); 
$.ajax( {
"dataType": 'json',
"type": "post",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}, 
"sDom": '<"tableTip">rt<bottom>lip',
"sPaginationType": "full_numbers",
"oLanguage": {
"sUrl":baseUrl+'js/common/111.txt'
},
"aaSorting": [[ 8, "desc" ]],
"aoColumns": [
{ "mDataProp": null,
"sWidth":"1%",
bSortable:false,
"fnRender": function(obj) {
var sReturn = '<img src = "'+baseUrl+'images/details_open.png" style = "vertical-align:middle;" title="点击展开详细信息" />';
return sReturn;
}
},
{ "mDataProp": null,
"sWidth":"1%",
bSortable:false,
"fnRender": function(obj) {
var sReturn = '<input type="checkbox" name = "checkRows"/>';
return sReturn;
}
},
{"mDataProp": null,
bSortable:false,
"sWidth":"5%"
},
{"mDataProp": "infoCateId",
"bSearchable": false,
"bVisible": false
},
{"mDataProp": "srcInfoId",
"bSearchable": false,
"bVisible": false
},
{"mDataProp": "title",
"sWidth":"23%",
bSortable:false,
"fnRender": function (oObj) {
var title = oObj.aData.title;
var infoCateId = o