This是一个基本的数据表小提琴。
这是default,下拉列表会显示以下Show options 10, 25, 50, 75 and 100 records:
现在我想要的是"lengthMenu": [ [10, 25, 50, -1], [10, 25, 50, "All"] ]
我可以在this fiddle。但是,如果我使用服务器端处理,这就是All
选项对我不起作用的地方。其他人呢。当我选择All
时,它会显示它显示的数据,而底部则显示No data found in the server
据我所知,唯一的区别是数据来自服务器。任何人都可以建议我怎么能麻烦拍这个?据我所知,当我选择All
我发送length:-1
而10
length:10
时,All
就是 $(document).ready(function() {
var dataTable = $('#employee-grid').DataTable( {
"lengthMenu" : [[ 10, 25, 50, -1 ],[ '10', '25', '50', 'All' ]],
//"pageLength": 25,
"processing": true,
"serverSide": true,
"ajax":{
url :"employee-grid-data.php", // json datasource
type: "post", // method , by default get
error: function(){ // error handling
$(".employee-grid-error").html("");
$("#employee-grid").append('<tbody class="employee-grid-error"><tr><th colspan="3">No data found in the server</th></tr></tbody>');
$("#employee-grid_processing").css("display","none");
}
}
} );
} );
,所以不确定为什么{{1}}无法正常工作{ p>
{{1}}
答案 0 :(得分:0)
“ lengthMenu”:[[10,25,50,-1],[10,25,50,“全部”]]
1)表示为“ ALL”分配了值-1。
2)这就是为什么当您选择“所有正在发送的长度:-1且10表示长度:10
3)这就是为什么您还在服务器中找不到数据-错误
的原因4)为此,请在您的控制器中提供
var length = Request.Form.GetValues(“ length”)。FirstOrDefault()==“ -1”吗? Convert.ToString(YOUR_LIST.Count()):Request.Form.GetValues(“ length”)。FirstOrDefault();
5)这将告诉您是否length == -1然后取列表总数,以便显示所有行。
答案 1 :(得分:-1)
使用服务器端处理时,您应该忽略start
和length
请求参数仅限 length
参数为-1
你的PHP脚本,以便返回所有记录。
答案 2 :(得分:-1)
对我来说,更改这些参数的前3个有效:
dom: 'ZBlrtip',
lengthMenu: [[100, 200, -1], [100, 200, "All"]],
bLengthChange: true,
order: [8, "desc"],
paging: true,
pageLength: 100,
serverSide: true