Hello, Attempting to get the desired operation out of server side datatable sorting I noted the documentation stated the following:
Now header clicking will trigger a server-side GET request with the following parameter: sort[package]=desc (data.php?sort[package]=desc), which allows sending:
In my testing this does hold true for the first column header that is clicked; however, if subsequent column headers are clicked to sort by a different column, the column names are added to the GET request array rather than replacing the previous. As a result the subsequent requests look like the following for example:
data.php?sort[col1]=desc&sort[col2]=desc&sort[col3]=asc
Is this the expected behaviour? I imagined sorting on only a single column and having that column name and sort ‘direction’ presented. Actually I’ve just noticed ALL the parameters of the GET request are duplicated - is this a known issue with v3.3.13
Thanks -SrvrSide
Hello, I upgraded the webix version to v4.2.4 and i’m seeing the same behaviour. Could someone possibly confirm if this is expected behaviour and if so perhaps offer a suggestion how one would implement server side sorting correctly?
Thanks for any assistance -SrvrSide
Hi, could you please provide a snippet where the issue can be spotted?
As far as I can see, there’s only one “sort” parameter per request: http://webix.com/snippet/924c2529
Hello Helga,
I systematically worked through the datatable that is exhibiting this behaviour and it boiled down to having an onBeforeLoad:function()
handler. I really don’t understand how or why this may alter the behaviour but if I comment out that handler it works as documented. If reinstate it I get the odd behaviour I mentioned above.
The example below shows the submissions when clicking the first, second and then third column headers in your snippet example after I added the handlers : snippet http://webix.com/snippet/752931db
http://docs.webix.com/samples/40_serverside/01_php_vanila/server/datatable.php?start=0&count=50&continue=true&sort[title]=asc
http://docs.webix.com/samples/40_serverside/01_php_vanila/server/datatable.php?start=0&count=50&continue=true&sort[title]=asc&start=0&count=50&continue=true&sort[year]=asc
http://docs.webix.com/samples/40_serverside/01_php_vanila/server/datatable.php?start=0&count=50&continue=true&sort[title]=asc&start=0&count=50&continue=true&sort[year]=asc&start=0&count=50&continue=true&sort[votes]=asc
Please let me know if you need anything else
Thanks
-SrvrSide
Hello Helga, were you able to replicate the issue?
-SrvrSide
Hello,
The problem is in your clearAll()
call in the onBeforeLoad
handler. It prevents from restoring the data url to a normal state.
You can either
- omit the line, as the data is cleared automatically before serverside sorting;
- or, if manual data clearing is needed for some reason, restore the url manually as
this.data.url = this.config.url
.
Please, check the snippet: http://webix.com/snippet/c57f2551
Thank you Helga,
Sorry to query something so stupid. As I recall I had added the clearAll() to make sure the “Loading…” overlay was visible. Thanks for the help (btw - the snippet at that link seems to be empty)
-SrvrSide
Yep, there’s been a global problem with our snippets. Here’s a working one: https://webix.com/snippet/bb2c1fbe