Page 1 of 3

storage models and array

Posted: Mon Oct 13, 2014 1:45 pm
by Michael4771079

Hi,
I have a question about the structure of a storage model and arrays
I have a service the returns all properties in a collection on a where using user login.
It all works fine but I want to speed us the app by loading this returned service in localstorage and then map from there as needed

Because I dont know how many properties are present, do I need to save all returned data to one array or would it be an array of arrays

if you have an example screenshot of the model structure it would be a great help
here is a screenshot of the mapping as it is now.

thanks alot, I really like this feature cheers!
Image


storage models and array

Posted: Mon Oct 13, 2014 3:55 pm
by Evgene Karachevtsev

Hello Michael,

There should be an array of objects with properties, not an array of arrays.


storage models and array

Posted: Tue Oct 14, 2014 7:32 pm
by Michael4771079

Hi Evgene,
this is great!
I implemented the above and it has made this part of the app really fast, no waiting for service, when panel opens data is already present as it was mapped from local storage on pageshow.

I wonder if the next is poss?
now that the favourite properties are in localstorage, how could I map the required property from the same localstorage when I click the more button?

here is a screenshot
really love this feature,
thanks!

Image


storage models and array

Posted: Tue Oct 14, 2014 8:52 pm
by Evgene Karachevtsev

Michael,

1 Create a generic service
2 Add the parameters in response tab
3 Map data on event success from local storage in the required elements on the page
4 When you click on the appropriate button, call this service


storage models and array

Posted: Tue Oct 14, 2014 9:04 pm
by Michael4771079

Cheers Evegene,
I dont see how this method would pull the correct property, there may be one property or five properties,


storage models and array

Posted: Wed Oct 15, 2014 10:50 am
by Kateryna Grynko

Hi Michael,

In mapping you can click JS button and add a JavaScript code to filter data as needed.


storage models and array

Posted: Thu Oct 16, 2014 1:42 pm
by Michael4771079

Hi Kateryna,
thanks for that,
I have saved the property _id to local storage and mapped my previous lsv to a grid on a panel when run all properties are listed,
so have you an example of the js I need to get the property _id from localstorage and print only this properties details

thanks very much,
Everything is so much quicker.
Best upgrade by far!


storage models and array

Posted: Thu Oct 16, 2014 8:23 pm
by Evgene Karachevtsev

Hello Michael,

There are 2 options
1) Create a generic service. In this service you can receive data from local storage. Parse them (JSON.parse), make a search on parsed data and return only the data that meet the search conditions.
2) Create a regular service which takes data from local storage and in mapping add js code to hide don't need data. It's easier to do. Here I will explain
Let's say you have this respons - screenshot 1
You want to make a filter on a field n of response. The value by which you should filter is stored in local storage variable nFilter.
Create the mapping - screenshot 2
Add js code in the mapping - screenshot 3
Results ot the test - screenshot 4

Image

Image

Image

Image


storage models and array

Posted: Mon Oct 20, 2014 12:52 pm
by Michael4771079

Hi Evegene
I have implemented the following
on login all properties in collection favs with this login are saved to local storage

created a model for favprop_id in local storage.

on login complete favprop_id is populated with all property ids in a array as following screenshot

Image

I deleted one of the ids manually to test, and added the js to the mapping from localStorage from which is of the more button


storage models and array

Posted: Mon Oct 20, 2014 1:04 pm
by Michael4771079

Hi Evegene
I have implemented the following

on login all properties in collection favs with this login are saved to local storage

Image

created a model for favprop_id in local storage.
on login complete favprop_id is populated with all property ids in a array as following screenshot

Image

I deleted one of the ids manually to test, and added the js to the mapping from localStorage to test

Image

Image

the result is error Error: c15r: component not found
unsure if this is my implementation or an upgrade problem as I am getting the error in another app also (since yesterdays upgrade)

Image