Custom searchable table - snippet (question)

Hello Dear All, 

i’m trying to create a searchable table built with two components and I have problems with that. Maybe someone can help me with this. I would be grateful. 

I have two components:
a) table component A used for defining the search parameters; 
b) table component B which shows the results with regard to above set parameters. 

Table A is mainly based on multi-picklist fields like:
Area_Master (with values: Sales, Operations, Languages, Warehouse); 
Area_Master_Score (with values: Air, Air&Sea, Road, Sea);

my problem is that while I am defining parameters in only one of this fields let’s say Area_Master = Sales, Operations and leave second field without selected values I don’t see an results because it search for Area_Master_Score = blank. And I would like to have an opposite logic i.e. if none value is selected than search for records which have any of values from that field. 

The same should work in another direction i.e. when I’m selecting some values I would like to get as the results records which have selected values in this match but + other values e.g. selecting Area_Master_Score = Air; Air&Sea should give me records having Area_Master_Score = Air; Air&Sea but also Area_Master_Score = Air; Air&Sea; Road, Sea etc. 

I.e. I don’t what to limit the results only for “perfect match”.

Can you help me and give me a hint how to create such feature?
Thank you.

I have done something similar I believe. I created a global filter UI that allows a number of different models to be filtered by this global filter across multiple screens. To accomplish this I essentially apply the filters to the model directly as they are changed. In the case where no filter is selected I deactivate that filter in the model that way it doesn’t get factored in. 

I have a function that basically does this work for me against the model. It takes the model, values, and condition name as arguments. See function below. If you have a snippet already that collects the values chosen by the user then all you have to do is use this method to set the conditions. 

Note: this does not perform the query for you. It just sets up the conditions. After calling this method you should use model.updateData() to run your query. This will allow you to set as many conditions by name as you need to and then run your query.

function setViewCondition(model, name, values) { var condition = model.getConditionByName(name); if (condition) { if (values && values.length > 0) { model.setCondition(condition, values, false); model.activateCondition(condition, false); } else { model.deactivateCondition(condition, false); } } }

Hope this along the lines of what you were looking for.