在我的Asp.net应用程序中,我有一个Gridview控件并将其绑定到后面的代码上。
在客户端,我使用Jquery DataTable version 1.9.4
以获得更好的排序,搜索功能,这是我遇到的一个问题,数值无法正确排序。
我用google搜索并使用sType": "numeric"
来解决问题,但是当我使用此工具时,我的整个工作停止了,我的列位于9位置,所以我将aTragets
设置为9
这是JS FIDDLE
Javascript:
$(document).ready(function () {
$('#ctl00_ContentPlaceHolder1_GridView3').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers"
// "aoColumnDefs": [{ "sType": "numeric", "aTargets": [9] }]
});
});
后面的代码:
在Page_PreRender上
if (GridView3.Rows.Count > 0)
{
GridView3.UseAccessibleHeader = true;
GridView3.HeaderRow.TableSection = TableRowSection.TableHeader;
}
在pageLoad上:
GridView3.DataSource = sortedDT;
GridView3.DataBind();
最佳答案
我认为aaSorting是您必须使用的
$(document).ready(function () {
$('#ctl00_ContentPlaceHolder1_GridView3').dataTable({
"aaSorting": [[ 9, "asc"]], /*row count starts from 0 in datatables*/
"bJQueryUI": true,
"sPaginationType": "full_numbers"
// "aoColumnDefs": [{ "sType": "numeric", "aTargets": [9] }]
});
});
更新
问题如我的评论
It clearly does not understand the numeric datatype of the column
所述。您的问题是,您的……内也有文字。看到一个有用的小提琴http://jsfiddle.net/6Pxwy/1