Page 1 of 3

How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 4:36 pm
by Marc6388140

I have a list of items in my startscreen and when I click one I would like the app to open screen1 and fill it with a list of items filtered by the one selected at the startscreen.

  1. Should I use "Labels" in the List component of startscreen, or I can use the "Text" field of the component to fill the data?
  2. How can I store the selected value to use it as filter?
  3. How do I set the list and the service in screen1 to retrive the filtered values?

How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 5:43 pm
by Kateryna Grynko

Hi Marc,

How do you generate the list? Do you enter data manually or using a service?


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 6:54 pm
by Marc6388140

(Edited)

Hi Katya, for the list in startscreen I enter the data manually. However the values I enter alredy exist in the database. For the list in screen1, values are retrieved from database.

Example of data:

Field 1: Alt Camp Field 2: Valls
Field 1: Alt Camp Field 2: Brafim
Field 1: Alt Emporda Field 2: Figueres

So, in startscreen I enter manually a list with the two distinct values of field 1: "Alt Camp" and "Alt Emporda", and when I click "Alt Camp", I want the app to open screen1 and show the list of Field 2, filtered by Field 1= Alt Camp: "Valls" and "Brafim".


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 10:26 pm
by Kateryna Grynko

Marc,

Run the following JavaScript code on Click event for item you map to:prelocalStorage.setItem("myValue",$(this).text());/preWhere 'myValue' is a name of variable where you save the content of item field 'text'.

You can read the variable value on the next page.


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 11:25 pm
by Marc6388140

I can't make it work.

I've set this mapping on the next page:

Image

Image

Where COMARCA is the field I want to filter by the variable "myValue" set at the previous page as adviced. No values are retrieved.


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Fri Nov 08, 2013 11:57 pm
by Marc6388140

I've tried with the following code in the clause "where":

return '{"COMARCA":"' + value + '"}'

but also failed.


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Sat Nov 09, 2013 2:17 am
by Igor

Hello,

Try to use next code:
prereturn '{"COMARCA":{ $regex: "'+value+'"}}';/pre


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Sat Nov 09, 2013 9:12 am
by Marc6388140

Tried with this code but it stil doesn't work. Maybe I need to add more code in the previous page, or change the events order?

Image


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Sat Nov 09, 2013 2:41 pm
by Alena Prykhodko

Please try the following:
pre
return '{"COMARCA":{"$regex":"'+value+'"}';
/pre


How to select a value in a list and retrieve data in a new page based on that value?

Posted: Sat Nov 09, 2013 4:02 pm
by Marc6388140

I doesn't work. Here the screenshot of the Chrome inspector:

Image