leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

I have the following screen and mapping setup:

  • a searchbar and a list ite

    Image

    Image

    The Image

    The query text in the request mapped to the searchbar is: code{"tit":{"$regex":"S", "$options":"i"}}/code

    This shows all titles starting with "S"
    I've read some tutorials but they're a little different. I need the steps to accomplish these:
    ul
    liGive all the titles at start and when the searchbar is empty/li
    liFilter the titles in the list to match the searchbar text as it is typed/li
    liGive all titles that match what is typed in the searchbar anywhere in the title, not only at the beginning of the title/li
    /ul

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

still awaiting help on this one.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Correct Procedure for a Searchbar query

Please add JS code below to the mapping searchbar-where:

prereturn value ? {"name":{"$regex":value, "$options":"i"}} : "";/pre

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

Perfect. Thanks.
Now, using the same method, I need to do the same in an expanded way to search for names. I have 4 name fields: nm1, nm2, nm3, nm4. I am only displaying nm1 as list items. When a text is typed in the searchbar, I want it to search for that value in all the name fields and display the corresponding name from nm1.

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

Putting the following code in the Where of the mapping of searchbar of the names page gives syntax error:
codereturn value ?'{"$or":[{"fns":{"$regex":value, "$options":"i"}} : "",{"nm1":{"$regex":value, "$options":"i"}} : "",{"nm2":{"$regex":value, "$options":"i"}} : ""]};/code

  1. What is the syntax to filter with the fields?
  2. How can I get the names to sort -- just the targeted fns?
  3. When testing the REST service, it seems the same syntax that goes in the mapping doesn't work directly in the Where field. Is there an explanation for this?
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Correct Procedure for a Searchbar query

1) It is an incorrect request. Please read here how to make multiple where clauses: https://devcenter.appery.io/documenta...
So your request shoud be like:
prereturn value ? {"$or":[{"fns":{"$regex":value, "$options":"i"}},{"nm1":{"$regex":value, "$options":"i"}},{"nm2":{"$regex":value, "$options":"i"}}]} : ""; /pre
2) Please use sort parameter for that: https://devcenter.appery.io/documenta...

3) You are right. Please look at the question #1

leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

Beautiful. Thanks. Two more thing:

  1. I want the search to be effected as the value of the searchbar changes. Currently, this is not implemented until a button or Enter is clicked.
  2. When the app is tested on the phone, the list is not updated to show the searched value, but it shows correctly in the development test. Is this a normal behavior?
Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Correct Procedure for a Searchbar query

  1. Please run search service on the keyup event of the search component for that
    1. No, it has to work the same. Please check if there are any errors in the Weinre console. You can learn here: https://devcenter.appery.io/documenta... how to open the console.
leonardo
Posts: 0
Joined: Thu Mar 14, 2013 7:04 pm

Correct Procedure for a Searchbar query

Thanks. It works perfectly now.

Return to “Issues”