How to remove values from filterbyvalue in Wijmo grid

Posted by: technical.store.technical on 9 July 2021, 12:31 am EST

    • Post Options:
    • Link

    Posted 9 July 2021, 12:31 am EST - Updated 3 October 2022, 1:21 pm EST

    Hi Team,

    We have a requirement where we are changing a displayed value in subjects column (English to ‘7’). So in case we will have to remove the english value from filter by value .

    Applied code - ( lines - 194-196)

    https://stackblitz.com/edit/angular-rownit?file=src/app/app.component.ts

    We want to remove this from filter since it is not displayed on the UI.

    Please provide Solution.

    Thank you.

  • Posted 10 July 2021, 1:06 am EST

    Hi team,

    Please provide solution.

    Thank you.

  • Posted 12 July 2021, 7:55 am EST

    Hi,

    To implement the above requirement, we may perform the following:

    • "* “We may make use of the editingFilter event of FlexGrid filter which occurs when a column filter is about to be edited by the user.”

    • “To get the filter for a given column, we may make use of getColumnFilter() of FlexGird filter which gets the filter for a given column.”

    • “We may use the getUniqueValues() method of valueFilter to get an array containing objects representing all unique values for this column.”

    • “We may perform the required manipulation and assign the final array to the uniqueValues property of ValeuFilter.”

      "

    Please refer to the code snippet:

      filterEditing(grid, filter, e) {
        if (grid.columns[e.col].binding == 'subjects') {
          let valueFilter = filter.getColumnFilter('subjects', true).valueFilter;
          let customUniqueValues = [];
          valueFilter.getUniqueValues().forEach(item => {
            if (item.value.indexOf('english') >= 0) {
              if (item.value.length > 1) {
                let str = item.text;
                str = str.replace('english', '');
                customUniqueValues.push(str);
              }
            } else {
              customUniqueValues.push(item.text);
            }
          });
    
          valueFilter.uniqueValues = customUniqueValues;
        }
      }
    
    

    Sample: https://stackblitz.com/edit/angular-tykcmw

    Regards,

    Ashwin

Need extra support?

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

Learn More

Forum Channels