what does fnSortListener do?
what does fnSortListener do?
Hello,
After looking at different sorting examples, and implementing multi-column sort, i still can't figure out what the fnSortListener does. i have seen threads where the fnSortListener was initially suggested, but later deemed unnecessary.
can i look at an example of the fnSortListener being used?
Thanks,
Nilesh
After looking at different sorting examples, and implementing multi-column sort, i still can't figure out what the fnSortListener does. i have seen threads where the fnSortListener was initially suggested, but later deemed unnecessary.
can i look at an example of the fnSortListener being used?
Thanks,
Nilesh
This discussion has been closed.
Replies
Generally speaking fnSortListener shouldn't be needed - however it can be used to attach the DataTables sorting listener (the click event on each TH element in the header) to any element you wish on the page. This can be useful if you want to control the table sorting from somewhere other than the header - which is unusual but possible.
I don't have an example running live of fnSortListener being used but there is a code example in the documentation.
Allan
I am attempting doing Pagination a similar way using the example: ( http://datatables.net/release-datatables/examples/plug-ins/paging_plugin.html ). Where I am going to make a REST call upon click of next or previous to get a json object back of the data I wish to be rendered in DataTables.
Meaning I have to update the tables meta data information (in the info, ex. "Showing X to Y of Z entries") accordingly with the meta data of the object that is returned from the server.
The reason for all this is, there is already a REST service in place, one of my requirements is to try to utilize that call with minimal modifications, so for the most part I'm able to do pagination/column sorting/ect, but it uses a slightly different format than DataTables. Therefore, I need to process the return into something DataTables can use along with process the call to something that is meaningful to the REST call.
Is there a more effective way of doing this?
You would unbind the default 'click' listener that DataTables adds and then add your own event handler that would call fnSort with the required values. Its not the most trivial piece of code, but its certainly possible to do it that way. fnSortListener isn't what you would want here, although you might code the code inside it useful if you wanted to replicate the exact behaviour.
Allan