• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 433
  • Last Modified:

How to use a wildcard when searching a dataset

Here is some code that I'm using:

++++START++++++++++
Search_btn.onPress = function() {
      if (this._parent.ReasonCode_ds.hasSort("Category")) {
      this._parent.ReasonCode_ds.removeSort("Category");
      }
      var SearchID:String = null;
      this._parent.ReasonCode_ds.addSort("Category",["Types"]);
      if (this._parent.ReasonCode_ds.findFirst([this._parent.Search_txt.text])) {
       SearchID = this._parent.ReasonCode_ds.getItemId();
         this._parent.ReasonCode_ds.locateById(SearchID);
      } else {
            this._parent.ReasonCode_ds.removeSort("Category");
      }
      
      
}
++++END++++++++++++

I want to be able to use a wild card when entering text into the --- Search_txt --- component. (i.e. "Lost *")

So, if I have multiple instances in the dataset of the word "Lost" and I want to do a search for all instances normally I would use something like "Lost *", however for some reason if I enter "Lost" or "Lost *" the search fails. I have to put in the exact phrase that is in the dataset before I get a successful search (i.e. "Lost Keys") if "Lost Keys" is one of the items in the data set then the search works.

I sure hope someone out there can help. It doesn't seem logical to have to do a search for an exact phrase when the user may not know what the exact phrase is in the dataset!

0
gemarti
Asked:
gemarti
  • 2
1 Solution
 
BillystyxCommented:
try using indexof

myString  .indexOf(  substring,  [ startIndex ] )

Billystyx
0
 
gemartiAuthor Commented:
Thanks Billystyx.....

I'm not really sure I follow your suggestion.

If I use the myString.indexOf(string,index) method then It looks like I'm have to iterate through each dataSet record, store the record to a string variable, evaluate for a match then store the index value to another variable. That seems a bit too time consuming. Is that what you are suggesting I do?

I can try, but if there is a better solution out there, I'd love to see it.
0
 
BillystyxCommented:
It is the only way I am aware of, gemarti. Hope it is enough to work for you.

Billystyx
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now