Page 1 of 2

Populating selects from rest service

Posted: Thu Oct 18, 2012 8:14 am
by Barbara

I have previously successfully populated selects from rest services, but there has always been only 2 columns in the response array.

This time I have 3 columns in my response array, two of which I map to a select. The other one is dealt with in the success event.

This is not working though, I see the returned json is good, but only the first row gets populated in the select.

Isn't it possible to do this? I don't want to have to get the data twice as it is all related and comes from one SQL query.


Populating selects from rest service

Posted: Thu Oct 18, 2012 8:17 am
by Maryna Brodina

Hello! Could you send us a screemshot of mapping?


Populating selects from rest service

Posted: Thu Oct 18, 2012 8:21 am
by Barbara

Hello Marina, where have you been I missed you Image


Populating selects from rest service

Posted: Thu Oct 18, 2012 8:24 am
by Maryna Brodina

I'm here :) Thank you, we'll take a look.


Populating selects from rest service

Posted: Thu Oct 18, 2012 12:05 pm
by Maryna Brodina

Barbara, could you clarify please in more details what are you trying to do? We tried to figure out, but no luck.


Populating selects from rest service

Posted: Thu Oct 18, 2012 12:19 pm
by Barbara

Ok I am returning a 3 column array from restservice

id, ingredient, aisle

I want to store id and ingredient in the select so an ingredient can be selected

I also need to know what aisle that ingredient is in so I run custom js on complete event of restservice to store the id and aisle for future reference.

So I mapped id and ingredient to the select, but only the first ingredient gets added to the select, which is actually just a placeholder with no id.

Does that help?


Populating selects from rest service

Posted: Thu Oct 18, 2012 12:28 pm
by Maryna Brodina

You should map ings[] to selectmenuitem1


Populating selects from rest service

Posted: Thu Oct 18, 2012 12:37 pm
by Barbara

Ooops, sorry missed that step. Woking now.

But my oncomplete js isn't

I now see jqXHR and textStatus in the event javascript. I assumed I could use jqxhr the same way as data, but it doesn't work

code
for (i in jqXHR.ings) {
ingid=jqXHR.ings.column1;
aisle=jqXHR.ings.column3;
hiddenhtml += "somehtml";
}
$('[name=hidden]').html(hiddenhtml);


Populating selects from rest service

Posted: Thu Oct 18, 2012 12:41 pm
by Maryna Brodina

It seems it's jqXHR.ings, the easiest way to find out is to do console.log on that object.


Populating selects from rest service

Posted: Thu Oct 18, 2012 1:10 pm
by Barbara

jqXHR.ings is undefined