Looking for a way to customize column sorting.
Looking for a way to customize column sorting.
Daveomania
Posts: 15Questions: 0Answers: 0
I have a datatable like so:
[code]
goTable = $("#<% =gvShipmentLines.ClientID %>").dataTable({
"sDom": '<"searchtable" rt><"toolbar"><"info" i>',
"bAutoWidth": false,
"iDisplayLength": 50,
"aoColumns": [
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "sType": "numeric" },
{ "sType": "numeric" },
null,
null,
{ "bSearchable": false },
null,
null,
{ "bSearchable": false },
{ "bSearchable": false },
null,
null,
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false }
]
});
[/code]
It is working just as planned. 1 problem I am trying to address is that it seems that although my types for a couple of columns in the table are ints, when I sort, they are sorted as text. Example: I have LineNumber as int, and if I have 11 rows in the table, and hit sort, i get 1,10,11,2,3,4,5,6,7,8,9.
I noticed that if I use [code] goTable.fnSort([[2,'asc']]); [/code] that it sorts properly when I load the table. What I want to know is how to cause my sort button at the tops of my rows to act this way.
If my explanation here is super shotty just let me know what you want to know and I will provide!
Thanks a lot this is driving me bananas!
Dave
[code]
goTable = $("#<% =gvShipmentLines.ClientID %>").dataTable({
"sDom": '<"searchtable" rt><"toolbar"><"info" i>',
"bAutoWidth": false,
"iDisplayLength": 50,
"aoColumns": [
{ "bSortable": false, "bSearchable": false },
{ "bSortable": false, "bSearchable": false },
{ "sType": "numeric" },
{ "sType": "numeric" },
null,
null,
{ "bSearchable": false },
null,
null,
{ "bSearchable": false },
{ "bSearchable": false },
null,
null,
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false },
{ "bSearchable": false }
]
});
[/code]
It is working just as planned. 1 problem I am trying to address is that it seems that although my types for a couple of columns in the table are ints, when I sort, they are sorted as text. Example: I have LineNumber as int, and if I have 11 rows in the table, and hit sort, i get 1,10,11,2,3,4,5,6,7,8,9.
I noticed that if I use [code] goTable.fnSort([[2,'asc']]); [/code] that it sorts properly when I load the table. What I want to know is how to cause my sort button at the tops of my rows to act this way.
If my explanation here is super shotty just let me know what you want to know and I will provide!
Thanks a lot this is driving me bananas!
Dave
This discussion has been closed.
Replies