Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

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?
Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

Hi Marc,

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

Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

(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".

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

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

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.

Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

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.

Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

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

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

but also failed.

Igor
Posts: 0
Joined: Tue Apr 02, 2013 12:05 pm

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

Hello,

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

Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

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

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

Marc6388140
Posts: 0
Joined: Tue Nov 05, 2013 3:04 pm

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

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

Image

Return to “Issues”