When I set datatable default sorting,limit is also change.
When I set datatable default sorting,limit is also change.
Zayar Htun
Posts: 6Questions: 1Answers: 0
In my program,I was using the button on first column and I don't want it to sort.So,I disable its sorting and using ==>('order', [[1, 'asc']]);<=== It was ok.But,when I change the limit of my data row and make a sorting.The limit is set to default.
for example; I have choose the limit to 50 to display 50 rows.And then,I sort the second column .Then, the limit become to 10 again and just display10 rows.How can I fix?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Are you using server side processing?
Kevin
Yes.It was server side processing.
It has been solved!!! I change ('order', [[1, 'asc']]); into ('order', [1, 'asc']);
It is because of 2D array.It change the data from model to default limit.By the way,I was using datatable in cakephp
I think there must be something else going on -
order
should be a 2D array!Allan
Yes.I think so,too. But I don't know the reason why? Please can you tell me if there is another way to solve?
I'd need a link to a test page showing the issue to have some idea of what is going wrong. Possibly the server-side script isn't correctly handling the 2D array?
Allan
In model, I was getting data from DB and order it like this ===>
$sql->order([$colName => 'asc']); // $sql is 'Select * from table_name'
And I post this data from model to controller and then to JS.
In Js==>
mytest.createTable().withOption('order', [1, 'asc']);
The first column is button.So,It was sortable in model.So,I change it to unsortable.But arrow key is not disappear.That's why I inserted above code in js to auto change the second column to appear arrow. I think I have used 1D array in model.So,I can use 1Darray in JS with withOption.Is that right?
P.S:Sorry about my english if there is something wrong.
Ah I see - thanks for the explanation. DataTables should always be sending the ordering array to the server as a 2D array (since that it how it handles multi-column ordering). What you would probably need to do is just take the first element from that array in your server-side script and use that.
Regards,
Allan
Thanks for your explain You give me many knowledge.