Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
How to set initial filtering in igGrid options in order to load the data already filtered??
posted

Hi. What we want to achieve in our current project is to save the user's settings like "sorting", "pageSize", "pageIndex" and "filtering" for the grid and when he/she loads it again, the grid will be loaded like the last time the user left it. We managed to set "sorting" with "columnSettings" option, also the "pageSize" and "pageIndex" in the options which we use for initializing the grid.

The problem is with the "Filtering". We couldn't find in the documentation any option which could allow you to set initial filtering and along this to update the UI respectively. What we want is to set all the settings in the options and load the grid with only one remote request, instead of loading it clean and then applying igGridFiltering, igGridPaging or igGridSorting methods, because in this way we have like 4 or more additional requests (all the features are set to remote type).

So is there a way to set the filtering in the features[] option the same way we did with the other settings?

Best Regards,
Georgi Tsvetkov

Parents
No Data
Reply
  • 23953
    Verified Answer
    Offline posted

    Hi Georgi,

    igGridFiltering doesn't have this functionality out of the box. However this functionality exists in $.ig.DataSource. As a workaround you can create an instance of $.ig.DataSource and set its parameters($.ig.DataSource.settings.paging, $.ig.DataSource.settings.sorting, $.ig.DataSource.settings.filtering) in the urlParamsEncoding callback . Then just pass the configured $.ig.DataSource instance to igGrid.dataSource option.

    Here is an example code:

     

    Code Snippet
    1. $.ig.loader(function () {
    2.     var ds = new $.ig.DataSource({
    3.         dataSource: "/Home/GetData",
    4.         responseDataKey: "Records",
    5.         urlParamsEncoding: function (owner, params) {
    6.             owner.settings.filtering.expressions.push({ fieldName: "Name", expr: "Adj", cond: "equals" });
    7.             owner.settings.sorting.expressions.push({ fieldName: "Name", dir: "desc" });
    8.             owner.settings.paging.pageIndex = 1;
    9.             return true;
    10.         }
    11.     });
    12.     $("#grid1").igGrid({
    13.         dataSource: ds,
    14.         autoGenerateColumns: false,
    15.         localSchemaTransform: false,
    16.         columns: [
    17.             { key: "Name", headerText: "Name" }
    18.         ],
    19.         features: [
    20.             { recordCountKey: 'TotalRecordsCount', pageIndexUrlKey: 'page', pageSizeUrlKey: 'pageSize', name: 'Paging', type: 'remote', pageSize: 5 },
    21.             { sortUrlKey: 'sort', sortUrlKeyAscValue: 'asc', sortUrlKeyDescValue: 'desc', name: 'Sorting', type: 'remote' },
    22.             { filterExprUrlKey:

     

     

    Hope this helps,
    Martin Pavlov

    Infragistics, Inc.

Children