Custom filter for keyword array

Posted by: chris.davis on 6 December 2017, 3:45 am EST

    • Post Options:
    • Link

    Posted 6 December 2017, 3:45 am EST

    Is it possible to create a custom FlexGrid filter for an array data type?

    My data set contains one column that contains an array of tags/keywords (e.g., [“cat”, “dog”, “mouse”]). The filter by value panel shows each unique combination as a comma-separated list. I’d like to be able to show each distinct keyword and filter based on whether it is contained in the array in each cell in the column.

    Thanks.

  • Posted 7 December 2017, 12:23 am EST

    Hi Chris,

    You can show uniqueValue list by setting uniqueValues for valueFilter. You have to handle filterChanged event and cancel this event to prevent default editing.

    Now, the custom logic can be written for specific column to filter values from column.

    Please refer to fiddle that shows how to update uniqueValues for valueFilter for country column and cancel default filtering.

    http://jsfiddle.net/71f4c0a8/7/

    ~Manish

  • Posted 8 December 2017, 3:17 am EST

    Hi,

    What I’m looking for is the ability to filter cells that may contain multiple values. In this example, if one of the rows contained both US and UK in the country column, I’d want to be able to select either of those values from the filter and have that row appear in the search result.

    Thanks.

  • Posted 10 December 2017, 10:13 pm EST

    Hi Chris,

    For this, filter function should be written for FlexGrid collectionView and should be handled this.

    For your reference, please refer to the updated fiddle for the same.

    http://jsfiddle.net/71f4c0a8/8/

    ~Manish

  • Posted 24 August 2018, 11:03 am EST

    Hi Manish,

    In regards to the fiddle above and what I have tried, the custom filter on the country column seems to break the multi column filtering. If you filter on the country column and then also filter on a different column it doesn’t work.

    Regards,

    Johnny

  • Posted 26 August 2018, 5:43 pm EST

    Hi,

    If we understand correctly then you would like to use custom filtering on one column along with default filtering on other columns. If that is the case then please refer to the following sample which implements the stated requirement:-

    https://stackblitz.com/edit/js-fkcrzq?file=index.js

    ~Sharad

  • Posted 27 August 2018, 6:45 am EST

    Thanks Sharad! That worked great!

    The above examples show how to ovewrite the valueFilter, do you have examples on how to customize the condtionFilter?

    We have a custom column and the datatype for that column is an object. We want to be able to use the condtionFilter to filter on a value within the object.

    Thanks,

    Johnny

  • Posted 27 August 2018, 8:39 pm EST

    Hi Johnny,

    You can customize the conditionFilter in a similar way as valueFilter.

    Please refer to the following sample which customizes conditionFilter to support object types:-

    https://stackblitz.com/edit/js-hm5fou?file=index.js

    ~Sharad

  • Posted 28 August 2018, 5:14 am EST

    Thanks again Sharad! The example you provided above works great!

    Regards,

    Johnny

Need extra support?

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

Learn More

Forum Channels