Topic: DataTable: Add events for column sort selections
I am currently looking at implementing server-side searching and pagination and I understand that the DataTable does not support this out of the box, which is fine. I will use an external pagination control, as well as that I would be using a custom searching component (partial view) anyways for specific search criteria for the application. However I would like to make use of the DataTable's excellent sorting UI in the column headers but I can see there aren't any events that I might hook into to trigger a data refresh on a sorting change. Right now the headers would just affect the sorting of the current view the grid has, which will be a single page.
Expected Result: When I click on a header to sort the data table, I would like to have the option of capturing an event with an identifier what column was clicked and the sort direction selected. This way I can compose a new search call with the appropriate sorting and then update the data table with the appropriate page of information.
Actual Result: If I load a single page of data then click on a sorting header, it will just sort the values current page.
Justification: If I am on Page 1 of 10 pages of records and go to sort by name, I expect that the grid would refresh to show the first page of all records sorted by name, not just sort the current page items by name.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Opened
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No
StevePy priority commented 1 year ago
Ideally, it would be nice to have a "serverSide" option on the control. All this option needs to do is if set, instead of handling pagination, sorting, and searching as it currently does (client side) it raises an event passing the current page #, page size, sorting column/direction(s) and search text details (search column/value) It is up to the developer to perform the appropriate search call and update the data grid automatically. The control just needs to raise the event with any of the pagination, sorting, search values are changed. (if pagination is to be supported sever side, or initially if simpler, only make it available with pagination turned off) This could be something like an "onSearch" event called when server or sort actions are triggered.
Mateusz Lazaru staff commented 1 year ago
or maybe
onSorting
event returning all the data you mentioned and the option to useevent.preventDefault()
on it to prevent the component from actually sorting?