views:

388

answers:

1

Hi, I'm trying to create a DOJO DataGrid populated using a dojo.data.ItemFileReadStore with very simple json data which has an ID and a description. When an event occurs, i need to filter the rows displayed based on the IDs. When its a single ID, i can fix it by just adding myGrid.setQuery({ID:"someIdIWant"});

Is there some way i can filter more than 1 ID in the same piece of codde? For ex i want to filter ID1 and ID2 to be shown. I do not have a REST url exposed, my data is populated as javascript variables. Can i still JsonQueryRestStore using just json data in JS vars or dojo.data.ItemFileReadStore?

+1  A: 

The dojo.data.ItemFileReadStore supports using regular expressions in the query. The code internal to the ItemFileReadStore uses dojo.data.util.filter.patternToRegExp() to identify whether or not the string value in your query could be parsed as a regular expression. However, to be more precise, you can pass a RegExp object in your query. The two options look like this:

myGrid.setQuery({ID:"123|124"});
    // or
myGrid.setQuery({ID: new RegExp("123|124")});

Both examples fetch the two items with ID "123" and "124" respectively.

Michael