Page 1 of 2

JavaScript Local Storage String Array - Can only access '0' element

Posted: Wed Apr 15, 2015 7:46 pm
by Todd Penny

Looking for help with the correct syntax and approach for getting the elements of a Javascript string array one at a time for an array created using a Model and declared in local storage.

This line below works and returns the correct value
var typevalue = Apperyio.storage.assetTypeListValues.get("$[0]");

This does not work
var typevalue = Apperyio.storage.assetTypeListValues.get("$[1]");

Thanks for any help.


JavaScript Local Storage String Array - Can only access '0' element

Posted: Thu Apr 16, 2015 5:39 pm
by Illya Stepanov

Hi Todd -

Could you please show us how you have defined your model and storage in the builder?


JavaScript Local Storage String Array - Can only access '0' element

Posted: Thu Apr 16, 2015 5:44 pm
by Todd Penny

Here are a couple of images that show this. Image Image


JavaScript Local Storage String Array - Can only access '0' element

Posted: Fri Apr 17, 2015 6:05 pm
by Serhii Kulibaba

Hi Todd,

How do you set values to this storage variables? Do they have more than one item?


JavaScript Local Storage String Array - Can only access '0' element

Posted: Fri Apr 17, 2015 7:12 pm
by Todd Penny

They are being set using the data returned from a RESTService.

See attached picture. I can see the first value when I access it using element '0' reference.

Image


JavaScript Local Storage String Array - Can only access '0' element

Posted: Sat Apr 18, 2015 7:07 am
by Serhii Kulibaba

Mapping like this doesn't save full response into the array.

1) Create Model and it's storage which cointains
assetTypeListValues and assetTypeListRef
http://gyazo.com/03f883b9159d2724b391...

2) Add Success event handler, which save data into storage variables:

preApperyio.storage.assetTypeList.set(data);/pre

3) please use the assetTypeList variable after it


JavaScript Local Storage String Array - Can only access '0' element

Posted: Thu Apr 30, 2015 7:28 pm
by Joe7349603

No intention to hijack this thread but I have somewhat similar issue.

I am using auto-complete for my app and the values I use in auto-complete are in a database where I have about 360 items. unfortunately my array only populates only 100 items from the database. Is there are limit as to how much I can push to my array. Here is the code I am using. I have also tried to specify the value of array with specified ''slots' but still no solution: var myarray= new array(360); Note that auto-completer works as intended but with only 100 Items

code
var Saccoarr = new Array();

$(data).each(function(){ Saccoarr.push($(this)[0].Sacco); });

Saccoarr = $.grep(Saccoarr,function(n){ return(n);});//remove all the null values from the array otherwise the Autocomplete wont work..

var sacco_keyword = localStorage.setItem("sacco_keyword", JSON.stringify(Saccoarr));

Appery("Sacco__textinput").autocomplete({source: Saccoarr});
/code


JavaScript Local Storage String Array - Can only access '0' element

Posted: Thu Apr 30, 2015 9:24 pm
by Joe7349603

Ignore this ..Found the solution which is adding Limit (1500) in the DB service.

I am still surprised that there would be a limit of 100


JavaScript Local Storage String Array - Can only access '0' element

Posted: Tue May 05, 2015 3:50 pm
by Todd Penny

Thanks. How do I reference the 'data' when it's the result of a REST call and I don't have a name reference for it?


JavaScript Local Storage String Array - Can only access '0' element

Posted: Thu May 07, 2015 8:42 pm
by Serhii Kulibaba

Could you clarify what do you want to do? Full service response is able in "data" variable, so all it's children are able as other json children.