Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

selectmenu undefined when mapped from localstorage

Michael.

Please look at this tutorial:http://blog.bismallion.com/map-appery...
It should provide you the following information:
1) what value LSV should have
2) how to map LSV with selectmenu

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi,
I had read everything that I can find on this issue and I have tried alsorts of variations, but im still getting problems

im doing something wrong.
Here are the screenshots for
collection,
model,
localstorage set up,
sucess mapping to LSV on login
result in localstorage after mapping
mapping to page from LSV
error in console on page

if theres anything else you need to see please ask

Im running out of time with this upgrade, my app will be deleted from app store

maybe a quicker solution to this would be an example of whats needed to implement this?

none of the examples or docs I have seen have a collection like mine being mapped to components in a grid.

collection
Image

model
Image

LSV setup
Image

sucess mapping to LSV on login
Image

result in localstorage after mapping
Image

mapping to page from LSV

1
Image

2
Image

error in console on page
Image

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

selectmenu undefined when mapped from localstorage

Michael,

Your problem is in data that you are providing to map on the page
http://gyazo.com/80233bc3e6d48f2f8605...
Your angloveipizza in the DB collection has sizeandprice column, that has an array of the strings, but you use it in the mapping as array of objects with the fields size and price.
The solution is to parse your string as an object before mapping.

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi Evegene,
unsure exactly what you mean here,
do you mean change the model?
Do you have a screenshot of what you changed to get you result?

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

selectmenu undefined when mapped from localstorage

Hi Michael -

I think that Evgene trying to say that you have 2 options:

First the hard one:

a) create separate collection for sizeandprice
b) add pointer column to anglovegpizza
c) use id of sizeandprice collection
d) update your list request for pizza - add parameter include sizeandprice

Second the easy one:

a) Save your response to localstorage variable
b) parse your string "{size=10 inch}, {price=5.00} " into valid json object for each entity in array to:
pre
code
anglovegpizzalist {
anglovegpizzalist{
...............
sizeandprice:{
{size: "10 inch"},
{price: 5.00}
}
}
}/code/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

Hi Evegene,
im still not getting any further with this, can I get a screenshot of the setup you used to get this result

http://gyazo.com/80233bc3e6d48f2f8605...

it would be greatly appreciated

thanks

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

selectmenu undefined when mapped from localstorage

Michael,

[quote:]I get a screenshot of the setup you used to get this result[/quote]
We opened the console on test, then just followed your steps:
1) once logged in to the app (use "a" as login and pass)
2) click new order btn
3) from menu click pizza
4)then click vegetarian pizza
We have noticed which LSV you map, so we output it to console. that it is all

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

OK, How do I resolve the problem, can you help or not?

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

selectmenu undefined when mapped from localstorage

"The solution is to parse your string as an object before mapping"

do you have the code to prase as an object, I have tried this but no good
.
codevar arr;
try {
arr = JSON.parse(value);
if ({}.toString.call(arr) !== "[object Array]") {
arr = [];
}
} catch ( e ) {
arr = [];
}
return {"array": arr};/code

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

selectmenu undefined when mapped from localstorage

Hello Michael,

For your service anglovegpizza on load event add js code to chickcnpizzaselectmenu-0 value param :
return JSON.parse(value).price;

and for Label param
return JSON.parse(value).size;

Return to “Issues”