How to Sort only the current page using Jquery Datatable

Related searches

I have been using Jquery datatable for many projects and it's working perfectly for all scenarios.

For my current project I require sorting to be happened only for current page but by default datatable will sort whole data and redraw the entire table.

I was sure there will be some simple configuration for enable this feature but couldn't find any except these lines from their forum

var table = $('#example').DataTable();

// Sort by column 1 and then re-draw
table
    .order( [[ 1, 'asc' ]] )
    .draw( false ); 

I tried this but it doesn't seems to make any effect. any one has implemented this successfully before please share your code.

datatables: sort only current pagination of table, I'm using datatables. And by default with pagination feature on sorting one column redraws all the table and puts you to the first page of paginated ones. Is there an� In sort_name() function we first get table and tbody then we use jQuery sort() function to sort name alphabetically by comparing 1st row 1st column to the 2nd row 1st column and then append the sorted row to tbody.Then we change the sorting order if the order is 'asc' then change it to 'desc' and vice versa for table sorting.You may also like

How to Sort only the current page using Jquery Datatable, For my current project I require sorting to be happened only for current page but by default datatable will sort whole data and redraw the entire table. I was sure� Using this format, DataTables can achieve single column ordering (i.e. just use one entry in the top level array), or multi-column ordering to the nth column (multiple entries in the array). For convenience, this method allows multi-column ordering to be performed by passing in either multiple 1D ordering arrays or a 2D ordering array.

how to keep current page after sorting? — DataTables forums, I'm using http://www.datatables.net version 1.9.4. After sorting I want to keep the current page but default behavior redirects me to the first page. Using the order initialisation parameter, you can set the table to display the data in exactly the order that you want. The order parameter is an array of arrays where the first value of the inner array is the column to order on, and the second is 'asc' (ascending ordering) or 'desc' (descending ordering) as required.

how to keep the current page after sorting with jquery/datatables?, After sorting I want to keep the current page but default behavior redirects me to But I had to perform a sort only on visible data because of client's requirement. page with How do I set the default sort column on a datatable using jQuery? Because I am loading the data as json, I don't have the option of setting td attributes. I solved it by using a js function utilizing moment. This function will format the date based on the current locale, but sort based on the raw date input YYYY-MM-DD

DataTables AJAX Pagination with Search and Sort - PHP, DataTables is a jQuery plugin which makes easier to add pagination. Rows display per page $columnIndex = $_POST['order'][0]['column']; It's the only way I could make AJAX pagination work in DataTables. October secondly, would you be able to convert your original server side using PDO please? DataTables has the option of being able to save the state of a table (its paging position, ordering state etc) so that is can be restored when the user reloads a page, or comes back to the page after visiting a sub-page. This state saving ability is enabled by the stateSave option.

DataTables is a powerful jQuery plugin for creating table listings and adding interactions to them. It provides searching, sorting and pagination without any configuration.

Comments
  • well there is no such thing i guess but you can specify which page on what column you want to sort onload table.page(10).draw( false );table.order( [ 3, 'desc' ] ).draw( false );
  • Thanks JSuar, Let me try this out and get back!
  • @ssilas777, I updated my answer with a working solution. Let me know if you see any issues.
  • This is really great, I appreciate your efforts on this, as you said as of now I also was not able to find a solution with in data-table, so I accept this as answer.
  • Hi rtuszk, I got your point and it definitely makes sense. But some times when we are doing a migration project for a client and all that client need is the exact replication of their existing functionality, we doesn't have no other option ;) Upvoted for the great explanation.
  • I am curious if there are any strong arguments to providing such functionality. I would gladly read them.
  • I wanted similar functionality until i read your post @rtruszk
  • This looks great!