数据表分页和服务器端处理
我遵循以下说明: http://datatables.net/release-datatables/examples/ server_side/server_side.html 但我没有得到分页(也没有在 bJQuery 模式或经典模式下)。一切工作正常(搜索、排序……),但我无法获得分页。
我有什么遗漏的吗?
代码如下:
$(document).ready(function() {
$('#datatable').dataTable( {
bJQueryUI : true,
"bProcessing": true,
"bServerSide": true,
sPaginationType: "full_numbers",
"sAjaxSource": "/returnjson"
} );
} );
谢谢!
编辑: 我将参数用引号引起来。谢谢。 dgw,这没有改变任何东西。我想要的是分页按钮与我的服务器端代码交互:
/*
* Paging
*/
$sLimit = " LIMIT 100";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = " LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
感谢您的帮助
编辑2: 我尝试使用 datatables/demo_table.css 和 datatables/demo_table_jui.css 但这没有任何改变。
再次感谢 !
I followed these instruction: http://datatables.net/release-datatables/examples/server_side/server_side.html
But I don't get the pagination (nor in bJQuery mode nor classic). Everything is working fine (search, ordering, ...) but I can't get the pagination.
Is there something I'm missing ?
Here the code:
$(document).ready(function() {
$('#datatable').dataTable( {
bJQueryUI : true,
"bProcessing": true,
"bServerSide": true,
sPaginationType: "full_numbers",
"sAjaxSource": "/returnjson"
} );
} );
Thank you!
Edit:
I wrap my parameters in quotation marks. Thanks.
dgw, this is changing nothing. That I want is that the paging buttons interact with my serverside code:
/*
* Paging
*/
$sLimit = " LIMIT 100";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = " LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
Thanks for your help
Edit 2:
I tried with both datatables/demo_table.css and datatables/demo_table_jui.css but this change nothing.
Thanks again !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的 iTotalDisplayRecords 设置不正确(过滤后的总记录)。
来源:http://datatables.net/usage/server-side
My iTotalDisplayRecords was not set correctly (Total records, after filtering).
Source: http://datatables.net/usage/server-side
例如,
在对
dataTable
的调用中指定。这应该显示分页。有关更多信息,请查看数据表参数参考,尤其是关于
sDom
的部分。Specify for example
within your call to
dataTable
. This should show the pagination.For more information have a look at the parameter reference of datatables especially the part about
sDom
.