Build a Dynamic Filter from a form

Highlighted
Deleted
Not applicable

Hi all...

 

Hopefully someone can help me out here. I have a custom form on an SP Page that I need to use for filtering list items that have been returnd via a REST call and are being displayed in a table using Office Fabric UI.

 

Form Fields are: Title, ID, Category (dropdown), Status (dropdown), ID#

 

So I need to build a dynamic filter string to filter list items, so if there is a value in one of those fields then easy done:

 

if (data.Title){

filter = "(substringof('" + data.Title + "',Title))"

}

etc etc etc for the other fields

 

But what I need to happen is that if there is value in the Title AND in one of the other fields I need to CONCATENATE a further AND expression eg:

 

if(data.Title && data.Category) {

filter = "(substringof('" + data.Title + "',Title)) AND (ItemCategory/Title eq '"+data.Category+"')"

}

that is ok for that particular scenario, but what I am struggling with if is handling all the other different types of combinations of potential filters that a user may select.......

 

pleeease help.....

 

1 Reply
Highlighted