Bug with Server Sort

Hi,

I think there is bug with server sorting when triggered from external code https://snippet.webix.com/2qu7hp42

when clicking the button to sort programmatically, markSorting icon is changing but sorting is not happening

Comments

  • Hello, @mgraph2010

    Currently, the sort method only provides client-side sorting.
    Server sorting (by clicking on the header, by changing the state) is performed by separate logic as a data reload.
    As a solution for the issue, you could trigger server-side sort via state.
    Please, check the snippet here https://snippet.webix.com/79mrclov

  • edited July 14

    Hi @AlenaLisava

    Thanks for your quick response. my code is much complicated than that snippet, I just created it to replicate the issue with sort() when using server side loading.

    I know about setState() but the issue with this is that it makes an extra Ajax call when used in my code, I need to set the sort on firstonAfterRender after pulling previous state from localStorage.

    I've tried this to prevent any events but it still makes the ajax call:

    $$('datatable').blockEvent();
    $$('datatable').setState({sort: { id: 'clicks', dir: 'asc' }});
    $$('datatable').unblockEvent();
    

    Thanks

  • I've found a workaround to double ajax call, I return false in onDataRequest to stop second ajax call when I change sort usingsetState on initial load:

    ....
    if (state.sort) {
        this.dt_do_not_reload = true;
        this.setState({ sort: state.sort });
    }
    ...
    onDataRequest: function (start, count) {
        if (this.dt_do_not_reload) {
            delete (this.dt_do_not_reload);
            return false; // cancelling default behavior
        }
    },
    ...
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!