The datatable to be sorted based on the input text column on loading the datatable.

The datatable to be sorted based on the input text column on loading the datatable.

puneet.jayeepuneet.jayee Posts: 18Questions: 8Answers: 0

I have a datatable and while loading - I want the records to be sorted based on the input text box column value. Could you please help me with an example.

Note- While loading the datatable - I want the records to be sorted based on the input text values.

Answers

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    The search option can be used to set the initial search term for the Datatable. Is this what you are looking for?

    Kevin

  • puneet.jayeepuneet.jayee Posts: 18Questions: 8Answers: 0

    Thanks Kevin for the response but I am looking for sorting function which can sort the data based on input text box values during the table initialization or first load.

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @puneet.jayee ,

    This is an example that @kthorngren did for another thread. This is search in input elements - use this in conjunction with his suggestion of search and all should be good.

    If any issues persist, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770
    edited January 2019

    I am looking for sorting function which can sort the data based on input text box values during the table initialization or first load.

    My thought was you would have an input on your page and the value of the search would be the value in the input. Maybe we aren't understanding your requirement. To understand better, as Colin mentioned, please provide a test case with what you want so we can help.

    EDIT: Here is an example:
    http://live.datatables.net/hemecese/1/edit

    Kevin

This discussion has been closed.