AnsweredAssumed Answered

Regexp question for dgrid filter

Question asked by jfaron44 on May 9, 2016
Latest reply on May 10, 2016 by jfaron44

I am using a filter for a simple dgrid in an application (code below extracted for simplification):

var value = (newValue + "").replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
               queryNameVal[queryProp] = new RegExp(value, "i");
               grid.eschoolsList.set("query", queryNameVal);

    

This works, but it finds all results for the input value, regardless of where it is in the data, in this case, names of schools. Thus if the data has "Randolph" and "Shafer", and the user types in an "r", both items are returned in the filter.  I would like it to only find results beginning with the input value, so that a user input "r" would only return schools beginning with the letter "r", and so on with any user input letter. I have found regexp expressions to search for first letter in a string, but I haven't been able to execute anything successfully in this scenario. Is it possible, and if so, any suggestions would be greatly appreciated.    

Outcomes