admin管理员组文章数量:1431918
I don't know if it's a bug, but I have a datatable+ajax with the following options:
"bServerSide": true,
"sAjaxSource": url,
"fnServerData": function (sSource, aoData, fnCallback) {
jQuery.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"sPaginationType": "bootstrap",
"aoColumns": [
{ "sName": "Id", "sType": 'numeric', "bVisible": false },
{ "sName": "PostingDate", "sType": 'Date' },
{ "sName": "Userid", "sType": 'string', "bVisible": false },
{ "sName": "DisplayName" },
{ "sName": "Description" },
{ "sName": "MainTag" },
{ "sName": "Tags" },
{ "sName": "HowMuch" }
]
I have a form where users can add rows and when they submit it I add data to the database with an ajax call and then call: jQuery('#mydatatable').dataTable().fnReloadAjax();
When a user click to sort the table by column "MainTag" my server-side ajax receives:
iSortCol_0 4
iSortingCols 1
And all bSortable_# are there, correctly from 0 to 7 (I have 8 columns as shown above.
Now my problem is iSortCol_0 is misleading, since the columns where hidden, if I don't have a mean to know which columns are hidden on the server I misinterpret iSortCol_0=4 sorting by the wrong column.
I can implement a workaround, sending the information of which columns are displayed or hidden externally to datatables but I have the feeling either I am doing something wrong or I have missed to find the answer to my problem in the documentation.
I don't know if it's a bug, but I have a datatable+ajax with the following options:
"bServerSide": true,
"sAjaxSource": url,
"fnServerData": function (sSource, aoData, fnCallback) {
jQuery.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"sPaginationType": "bootstrap",
"aoColumns": [
{ "sName": "Id", "sType": 'numeric', "bVisible": false },
{ "sName": "PostingDate", "sType": 'Date' },
{ "sName": "Userid", "sType": 'string', "bVisible": false },
{ "sName": "DisplayName" },
{ "sName": "Description" },
{ "sName": "MainTag" },
{ "sName": "Tags" },
{ "sName": "HowMuch" }
]
I have a form where users can add rows and when they submit it I add data to the database with an ajax call and then call: jQuery('#mydatatable').dataTable().fnReloadAjax();
When a user click to sort the table by column "MainTag" my server-side ajax receives:
iSortCol_0 4
iSortingCols 1
And all bSortable_# are there, correctly from 0 to 7 (I have 8 columns as shown above.
Now my problem is iSortCol_0 is misleading, since the columns where hidden, if I don't have a mean to know which columns are hidden on the server I misinterpret iSortCol_0=4 sorting by the wrong column.
I can implement a workaround, sending the information of which columns are displayed or hidden externally to datatables but I have the feeling either I am doing something wrong or I have missed to find the answer to my problem in the documentation.
Share Improve this question edited Oct 6, 2013 at 17:30 madth3 7,34412 gold badges52 silver badges74 bronze badges asked Feb 27, 2012 at 15:10 Max FavilliMax Favilli 6,4693 gold badges43 silver badges64 bronze badges1 Answer
Reset to default 4I don't think that there is an automatic way to know that, what i'd do is send an extra parameter to the server using fnServerParams()
(as detailed in this example) to inform the server about what columns are hidden
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "more_data", "value": "my_value" } );
}
本文标签: javascriptAjax sorting serversideis iSortCol0 considering hiddend columnsStack Overflow
版权声明:本文标题:javascript - Ajax sorting server-side, is iSortCol_0 considering hiddend columns? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745591180a2665207.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论