Page 1 of 1
Correct Procedure for a Searchbar query
Posted: Tue May 31, 2016 8:19 am
by leonardo
I have the following screen and mapping setup:
a searchbar and a list ite
The
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
Correct Procedure for a Searchbar query
Posted: Wed Jun 01, 2016 1:00 pm
by leonardo
still awaiting help on this one.
Correct Procedure for a Searchbar query
Posted: Wed Jun 01, 2016 2:05 pm
by Serhii Kulibaba
Please add JS code below to the mapping searchbar-where:
prereturn value ? {"name":{"$regex":value, "$options":"i"}} : "";/pre
Correct Procedure for a Searchbar query
Posted: Wed Jun 01, 2016 6:24 pm
by leonardo
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.
Correct Procedure for a Searchbar query
Posted: Thu Jun 02, 2016 1:06 am
by leonardo
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
- What is the syntax to filter with the fields?
- How can I get the names to sort -- just the targeted fns?
- 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?
Correct Procedure for a Searchbar query
Posted: Thu Jun 02, 2016 3:45 pm
by Serhii Kulibaba
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
Correct Procedure for a Searchbar query
Posted: Thu Jun 02, 2016 7:51 pm
by leonardo
Beautiful. Thanks. Two more thing:
- 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.
- 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?
Correct Procedure for a Searchbar query
Posted: Fri Jun 03, 2016 5:03 pm
by Serhii Kulibaba
- Please run search service on the keyup event of the search component for that
- 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.
Correct Procedure for a Searchbar query
Posted: Fri Jun 03, 2016 8:39 pm
by leonardo
Thanks. It works perfectly now.