Option to filter by Cell's meta data

Tags: #<Tag:0x00007efc620b6b88>

Hi,
I am just wondering if we can apply a kind of condition to the cell’s metadata while filtering.
For now, I think we have option to filter only by the source data on the table with the help of
addCondition method.

Let’s say I apply color to a cell via cell’s metadata and I want to filter with that same color then I have no option to filter them right? So it would be good to have a filtering option by cell’s metadata. Or can we achieve that?

Thanks in advance!

Hi @subashdbc

the official filter is based only on data so if you’d like to filter by metadata you’d need to prepare something custom. I think that this is a very interesting case and would like to try it myself.

How would you like to filter those values?

  • button with predefined filter
  • input for all columns
  • input for particular column
  • dropdown menu option like ‘filter by value’
  • or maybe something else?
1 Like

@aleksandra_budnik yeah

dropdown menu option like ‘filter by value’

sounds good for especially for cell meta data

1 Like

I see a couple of ways you can achieve it, but the first thing to do is to build a custom dropdown menu option. Fortunately, I have a demo for that http://jsfiddle.net/AMBudnik/oxLsr2ch/ (it also shows how to hide an option for some columns).

Building something more than just label/button requires the beforeKeyDown hook to block closing menu too quickly.

Once you’d get the UI done you’ll be able to get to the good stuff. I guess that getSelected can be the used to tell you what column is focused for the menu. Then… you can read the column metadata by getCellMeta (and doing a loop for all the rows) or you can keep those settings is a separate array and just make a call to it. It’s hard to tell which option of those two is better but the separate-array option sounds faster.

How to make the custom filter by cell’s meta data? I add the check box(=value is meta data) on dropdown menu. If checkbox was checked, filterd table.

Hey @corea.jk.1224

the Filters plugin by default it works only for data, so true - you need to create a custom option. Here’s an example of a custom dropdown menu based on the column index http://jsfiddle.net/AMBudnik/bs0r38qh/ I hope that it will help you to create the example.

Hi, @aleksandra_budnik

I knew a method of add custome option on drop menu. But I wanna filterd by meta props. How to add condition of meta props in the filter plugin? ex) filtersPlugin.addCondition(1, ‘eq’, meta pops)

Hey @corea.jk.1224

as mentioned before

the plugin’s methods do NOT work for metadata.

That is a custom example and we do not have any plugins to help you with this task.
You do not need to construct a plugin to get this working but you may need some example logic besides getCellMeta and getSelected.

If you need more help please share your license ID at support@handsontable.com

1 Like