Possible to disable client header ordering while still allowing API ordering serverside

Possible to disable client header ordering while still allowing API ordering serverside

JeffAF1221JeffAF1221 Posts: 2Questions: 1Answers: 0

Link to test case: http://live.datatables.net/gilihego/1/edit?html,js
Debugger code (debug.datatables.net):
Error messages shown: none
Description of problem: I am trying to have custom headers that allow for both ordering and individual column searches within data tables for several tables throughout my app. Problem is that what I currently have works perfectly when done so client side, but breaks when done so server side. I set orderable: false for all of the columns (using columnDefs) and that works client side but as soon as I use this on a table using server side it disables ordering for the columns all together (including initial ordering and API ordering). Is there a work around or another way for me to only disable the header ordering (column ordering when a user clicks a header), without also disabling the ability to order a column using the api?

I created a test case to show the code I have (however I am unsure how to simulate serverside through this so its really just the code)

I did however create some pages that simulate the problem as well so you can actually see it.

  1. https://t2ucms.com/morrow/dt_serverside_help1.php -- this shows how ordering doesn't work at all when I set ordering false to all of the columns.
  2. https://t2ucms.com/morrow/dt_serverside_help2.php --this is the same as above only i commented out the ordering false to show how it does order (however you will also notice how when you click inside the input field it ALSO sorts which is what I am trying to avoid)
  3. https://t2ucms.com/morrow/dt_serverside_help3.php --this is the same as the 1st only it is NOT server side and works perfectly. This is what I am trying to achieve, but done server side as the dataset I will be pulling in is too much without server side processing.

Code can be seen at:http://live.datatables.net/gilihego/1/edit?html,js

Thank you so much in advance for your time and help and please let me know if I can clarify anything or if further information/code is needed. =)

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 14,174Questions: 25Answers: 3,344
    Answer ✓

    Sounds like your server side script is using the columns[i][orderable] to determine if ordering can take place on that column. I believe the example ssp.class.php script uses this parameter to determine if the column is orderable. This can be changed in the server side script to ignore the paramter.

    Another alternative is to use two headers; one for sorting and the other for the search inputs. See this example. Note the use of orderCellsTop to move the sorting events to the top row.

    Kevin

  • JeffAF1221JeffAF1221 Posts: 2Questions: 1Answers: 0

    Thank you for the quick reply. I will have to check into having the server side script ignoring that parameter, and if not I think that other example you provided would work just fine as well. Thank you so much for the help! =)

Sign In or Register to comment.