grid.store.on('sort', ({ sorters }) => console.log(sorters));
// or in your example
store : {
listeners : {
sort({ sorters }) {
console.log(sorters);
}
}
}
I tried with the second one shown in the code. Removed the sortable parameter and added the store one, whereas I didn't get any logs in the console of the browser, not even the control went into this listener property inside the store object while debugging.
Could you please suggest where it could went wrong ?
If you used AjaxStore with remote sorting, there is no need to do data fetch by yourself, the store will request data after every sort change with params in format you provided using https://bryntum.com/docs/grid/api/Core/data/AjaxStore#function-encodeSorterParams
In this case there is no sort event will be triggered since no sort was done on the client side, actually it's just reload with new set of params. In this case that need to listen is https://bryntum.com/docs/grid/api/Core/data/AjaxStore#event-load . But the data is already fetched, so what is the case to do it again by listening to this event.
Hi Alex,
Thanks a lot.
But I tried using load event, it's not working.
You can suggest me better about how to proceed with my objective to achieve.
I have a POST request to send from the UI.
Post request is having some filter attributes and want to send sorters along with that, so that the POST method can return the resultset from the backend by imposing the where condition with filter attributes and within the order by clause I can put my sorter attributes (whether it is ASC/DESC) at the backend.
So, All the need is to send the sorters along with my filter attributes to that POST method as once the user clicks either on single or multiple columns from the Bryntum grid.
Hello.
Please check out this demo: https://bryntum.com/examples/grid/php-paged/ It uses remote sorting and remote filtering. When you sort columns (add multiple sorters) or add a filter new request is triggered to the configured readUrl with sorting/filtering params passed inside the querystring:
Since it is a readUrl it will use GET method, not POST. If you implement your data load handler to process these args you should be covered.
I have a POST request to send from the UI.
Why do you need to send a POST request from the app? Applying filtering/sorting is essentially data reloading operation. Dataset can be replaced manually of course, but in that case you would need to reimplement all that logic of encoding filters/sorters that already exist there.
Can you update handler that provides grid with the data to accept sort/filter params?