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?
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.
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.
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.
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)
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.