Page 2 of 4

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

Posted: Thu Nov 20, 2014 4:42 am
by Yurii Orishchuk

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.


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

Posted: Thu Nov 20, 2014 1:22 pm
by Sunita

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?


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

Posted: Fri Nov 21, 2014 12:02 am
by Yurii Orishchuk

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.


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

Posted: Fri Nov 21, 2014 2:00 pm
by Sunita

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?


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

Posted: Sat Nov 22, 2014 1:18 pm
by Alena Prykhodko

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.


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

Posted: Sat Nov 22, 2014 5:25 pm
by Sunita

Hi Alena,

Thank you for your reply.

Can you please show how to do that?


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

Posted: Sun Nov 23, 2014 11:23 pm
by Yurii Orishchuk

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.


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

Posted: Mon Nov 24, 2014 1:13 am
by Sunita

Hi Yuuri,

Thank you so much for your reply.

Where do I add the first block of code?

Regards


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

Posted: Mon Nov 24, 2014 4:59 am
by Yurii Orishchuk

Sunita,

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

Regards.


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

Posted: Mon Nov 24, 2014 11:41 am
by Sunita

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