gpt4 book ai didi

Jquery/Bootstrap DataTable 排序无法正常工作

转载 作者:行者123 更新时间:2023-12-01 08:00:07 25 4
gpt4 key购买 nike

 $('#StudentTable').dataTable({

"aaSorting": [],
"bSorting": false,
"bProcessing": false,
"bPaginate": false,
"bFilter": false,
"bDestroy": false,
"bAutoWidth": true,
"sScrollY": "224px",
"aoColumns": [
{ "sTitle": "StudentId" },
{ "sTitle": "Name" },
{ "sTitle": "Address" },
{ "sTitle": "Mobileno" },
{ "sTitle": "Email" }
],

"aaData": Students
});

我动态地将数据绑定(bind)到数据表...但问题是排序无法正常工作..它将正确对 Studentid 1 到 10 进行排序,但如果它大于 10,它将在顶部出现一些 Studentid。您可以看到以下输出排序

See output of sorting order

最佳答案

您需要告诉dataTable每一列存在哪种数据类型。将 StudentId sType 设置为 "sType": 'numeric' 它应该正确排序。

$('#StudentTable').dataTable({

"aaSorting": [],
"bSorting": false,
"bProcessing": false,
"bPaginate": false,
"bFilter": false,
"bDestroy": false,
"bAutoWidth": true,
"sScrollY": "224px",
"aoColumns": [
{ "sTitle": "StudentId", "sType": 'numeric' },
{ "sTitle": "Name" },
{ "sTitle": "Address" },
{ "sTitle": "Mobileno" },
{ "sTitle": "Email" }
],

"aaData": Students

});

关于Jquery/Bootstrap DataTable 排序无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20539926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com