Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Add an item from one list on one page to another list on a different page.

Hi Sunita,

Yes, that's exactly how i understand what you want to implement.

So the solution suggested above - good for your case. Please implement it as suggested.

Regards.

Sunita
Posts: 0
Joined: Sat Nov 15, 2014 2:40 pm

Add an item from one list on one page to another list on a different page.

Hi Yuuri,

I implemented as you suggested. But when i click on + My Veg, it reads all the items from listpage_1 onto detailspage_2 instead of just choosing one item (list1_item).

Any suggestions as to what is going wrong?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Add an item from one list on one page to another list on a different page.

Hi Sunita,

It seem's you don't set "where" parameter in list service datasource.

Please show us this mapping and JS code for "where" parameter screen shots.

For example you should have:
1 Link from LSV to "where" request parameter.
2 JS code in JS section of this link:

pre

//Get id from link.
var objectId = value;

//Take a look on console to see what actually passed to this "where" parameter.
console.log("objectId = " + objectId);

var whereObject = {"_id": objectId};
return JSON.stringify(whereObject);

/pre

Regards.

Sunita
Posts: 0
Joined: Sat Nov 15, 2014 2:40 pm

Add an item from one list on one page to another list on a different page.

Hi Yuuri,

Yes i realised I had not set "where" parameter. I have done what you have said above, and the app does the job that it could not earlier.

This is what I have done now:

Image

Image

Now, after doing this, it does add the item to the "My Veg" page. See below:

Image

But when i try and add another item, it replaces it with the old one:

Image

How do i add and list multiple items?

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

Add an item from one list on one page to another list on a different page.

Hello,

1) Save all id to array object
2) Your where query should be changed so it gets from DB all ids that you would like to retrieve.

Sunita
Posts: 0
Joined: Sat Nov 15, 2014 2:40 pm

Add an item from one list on one page to another list on a different page.

Hi Alena,

Thank you for your reply.

Can you please show how to do that?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Add an item from one list on one page to another list on a different page.

Hi Sunita,

So you need functionality like "Fafovites" or "Cart" where you can add items.

Here is some details:

  1. Specify your storage as "Array".

    Details:
    http://prntscr.com/59h645/direct
    http://prntscr.com/59h6m4/direct

  2. Use code like below to add items in array.

    pre

    //You should replace 34 with actual value.
    var currentId = 34;

    var favorites = Apperyio.storage.favorites.get();
    if(!favorites)
    favorites = [];

    favorites.push(currentId);

    Apperyio.storage.favorites.set(favorites)

    /pre

  3. Use following code in where clause for goal list:

    pre

    var favorites = Apperyio.storage.favorites.get();

    //Take a look on console to see what actually passed to this "where" parameter.
    console.log("favorites = " + JSON.parse(favorites));
    var whereObject = {"_id": {"$in": favorites } };
    return JSON.stringify(whereObject);

    /pre

    Regards.

Sunita
Posts: 0
Joined: Sat Nov 15, 2014 2:40 pm

Add an item from one list on one page to another list on a different page.

Hi Yuuri,

Thank you so much for your reply.

Where do I add the first block of code?

Regards

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Add an item from one list on one page to another list on a different page.

Sunita,

You should use this code when you need to add items to your favorites. For example on "click on list2_item".

Regards.

Sunita
Posts: 0
Joined: Sat Nov 15, 2014 2:40 pm

Add an item from one list on one page to another list on a different page.

Yuuri,

What will be the currentID in the first block of code? Will it be the same ID used to display the details of the vegetables?

And is that favorites your storage variable?

Lastly, where does the Array "A" come in this code, because I dont see it anywhere?

Regards

Return to “Issues”