views:

461

answers:

1

I have a Dojo Grid that I'm filtering with a query that's set in a javascript function.

function filter() {
    var grid = dojo.byId("gridNode");
    grid.setQuery({fieldName:"Some Text"});
}

What I'd really like to do, though, is filter it so that it shows all entries where the fieldName value is not empty. Does anyone know if there's a way to do this with the Dojo Grid Query, or any other solution that will work with Dojo Grid?

+2  A: 

If you are using dojo 1.4 and an dojo.data.ItemFileReadStore you can use a regular expression so the following should work:

grid.setQuery({fieldName:"[^]+"});

According to the following documentation page, not all of the data stores may implement regular expression usage in the query but you can try it out: http:(slash)(slash)docs.dojocampus.org/dojo/data/ItemFileReadStore

(replace slash slash with //, as a new user, spam prevention prevents me from posting more than one hyperlink)

You might also want to look into using the filter property of the Grid to accomplish what you want, if you want to filter based on some input. Look at this example: http://docs.dojocampus.org/dojox/grid/DataGrid#filtering-data

It would basically just be something like:

grid.filter({fieldName:"[^]+"});
JoseM