Dojo DGrid RQL Search -
i working dgrid want find search term in grid on 2 columns.
for instance, want see if scientific name , commonname columns contain string "aca" (i want search case insensitive)
my grid definition:
var customgrid = declare([grid, pagination ]); var gridstore = new memory({ idproperty: 'tsn', data: null }); gridstore.queryengine = rql.query; grid = new customgrid({ store: gridstore, columns: [ { field: "tsn", label: "tsn #"}, { field: "scientificname", label: "scientific name"}, { field: "commonname", label: "common name",}, ], autoheight: 'true', firstlastarrows: 'true', pagesizeoptions: [50, 100], }, id);
with built in query language (i think simple query language), able find term in 1 column or other, couldn't complex search return results both columns.
grid.set("query", { scientificname : new regexp(specieskeyword, "i") }); grid.refresh()
i started reading , think rql can solve problem, however, struggling syntax.
i have been looking @ these pages:
http://rql-engine.eu01.aws.af.cm/
https://github.com/kriszyp/rql
and able understand basic queries, "contains" syntax eludes me.
for instance if had simple data set , wanted find entries scientific , common names contain string "aca" think contains query this:
contains(scientificname,string:aca)
however, results in no matches.
[ { "tsn": 1, "scientificname": "acalypha ostryifolia", "commonname": "rough-pod copperleaf", }, { "tsn": 2, "scientificname": "aegalius acadicus", "commonname": "northern saw-whet owl", }, { "tsn": 3, "scientificname": "portulaca pilosa", "commonname": "2012-02-01", }, { "tsn": 4, "scientificname": "accipiter striatus", "commonname": "kiss-me-quick", }, { "tsn": 5, "scientificname": "acorus americanus", "commonname": "american sweetflag", } ]
can guide me in how formulate correct syntax? thank you.
from i'm briefly reading, appears that:
contains
replacedany
,all
- these meant array comparisons, not string comparisons
i'm not sure offhand whether regexps can handed other operations e.g. eq
.
with dojo/store/memory
, can pass query function allow whatever want, if wanted compare match in 1 field or other this:
grid.set('query', function (item) { var scientificrx = new regexp(specieskeyword, 'i'); var commonrx = new regexp(...); return scientificrx.test(item.scientificname) || commonrx.test(item.commonname); });
of course, if want filter items match both, can simple object syntax:
grid.set('query', { scientificname: scientificrx, commonname: commonrx });
Comments
Post a Comment