gpt4 book ai didi

javascript - 数据表: sorting not working

转载 作者:行者123 更新时间:2023-12-03 04:23:06 25 4
gpt4 key购买 nike

请帮忙。我不知道我哪里出错了我希望表格按第一列排序。我尝试了几种变体,但排序无法正常工作

dataTable = $("#deptDtTable").dataTable({
"bFilter" : false
"bProcessing" : true,
"bServerSide" : true,
"bSort" : true,
"bStateSave" : false,
"iDisplayLength" : 25,
"iDisplayStart" : 0,
"fnDrawCallback" : function() {
},
"sAjaxSource" : "/url/url/datatable/dept",
"aaSorting": [[ 1] ],
"aoColumns" : [
{
"mData" : 'id'
}, {
"mData" : 'client_name'
}, {
"mData" : 'ssn'
}, {
"mData" : 'department'
}, {
"mData" : 'account_id'
}, {
"mData" : 'dateEntered',
"render" : function(data) {
if (data !== null) {
var date = new Date(data);
return date.toLocaleString();
} else {
return '';
}
}
} ]
});

最佳答案

这就是我所做的,排序在第一列上进行。

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index62</title>
<script src="~/Scripts/jquery-1.12.4.min.js"></script>
<script src="~/Scripts/DataTables/jquery.dataTables.min.js"></script>
<link href="~/Content/DataTables/css/jquery.dataTables.min.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function () {
$('#example').
dataTable({
"processing": true,
"serverSide": true,
"info": true,
"stateSave": true,
"ajax": {
"url": "/Home/AjaxGetJsonData",
"type": "GET"
},
"columns": [
{ "data": "Name", "orderable": true },
{ "data": "Age", "orderable": false },
{ "data": "DoB", "orderable": true }
],
"order": [[0, "asc"]]
});
});

</script>
</head>
<body>
<div style="margin:30px;">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr style="text-align:left;">
<th>Name</th>
<th>Age</th>
<th>DoB</th>
</tr>
</thead>

<tfoot>
<tr style="text-align:left;">
<th>Name</th>
<th>Age</th>
<th>DoB</th>
</tr>
</tfoot>
</table>
</div>
</body>
</html>

关于javascript - 数据表: sorting not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43857153/

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