Server side filtering without using ODATACOllectionView

Posted by: rizwan on 3 January 2020, 3:35 am EST

    • Post Options:
    • Link

    Posted 3 January 2020, 3:35 am EST

    currently, i am using ‘sortedcolumn’ event for server side sorting, is there any event for filtering and paging ? because i do not want to change my server side endpoints.

  • Posted 6 January 2020, 3:33 am EST

    Hi Rizwan,

    The paging and filtering in the FlexGrid are done by CollectionView and FlexGridFilter class respectively. Therefore, you will need to handle the events for these classes.

    For paging, you can use the pageChanging or pageChanged event of the CollectionView class.

    For filtering, you may use the filterChanged and filterApplied events of the FlexGridFilter class.

    Regards,

    Ashwin

  • Posted 6 January 2020, 8:53 am EST

    Thanks for your reply i am able to make server calls in sortedcoulmn, filterApplied etc. But i am having issues using these. for example when i need to disable client side sorting which i am trying to do by

    event.cancel = true

    in ‘sortedcolumn’ event but it still does client side sorting. It only works in ‘sortingColumn’ event but there i am unable to get ‘sortDescriptions’. Please let me know how can i make server api call in by making client side sorting disabled with ‘sortingColumn’ event or is there any other way that does not use OData.

  • Posted 6 January 2020, 11:42 pm EST

    Hi Rizwan,

    From looking at your requirements, I would suggest you use the ServerCollectionView class. This class extends the CollectionView class and can be used to sort and filter the data on the server-side. Paging can also be done on the server-side using this class. Please refer to the link below for a demo:

    https://demos.wijmo.com/5/SampleExplorer/SampleExplorer/Sample/ServerCollectionView

    The ServerCollectionView class is not shipped with our official wijmo package so to use it, you can copy it directly from the source code. Also, you can disable client-side sorting by setting the sortOnServer property to true.

    Please note that this class uses REST API to modify the data on the server directly, Therefore, the server should have all the REST APIs implemented.

    Let me know if there is any doubt or you face any issues.

    ~regards

  • Posted 7 January 2020, 2:34 am EST

    Hi Ashwin,

    can i achieve this without ServerCollectionView class? Since i do not want to change my server implementation and it has to be simple.

  • Posted 8 January 2020, 1:42 am EST

    Hi Rizwan,

    In the sortedColumn event, you can save the sortDescriptions of the CollectionView and then clear them to reset the sorting:

    var grid = new wjcGrid.FlexGrid('#grid', {
      itemsSource: getData(),
      sortedColumn: (s) => {
        console.log('sorted');
        // save sort description
        var sd = JSON.stringify(s.collectionView.sortDescriptions);
        s.collectionView.sortDescriptions.clear();
      }
    });
    
    

    https://stackblitz.com/edit/js-xpopgf

    ~regards

  • Posted 8 January 2020, 5:08 am EST

    Thanks Ashwin :slight_smile:

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels