Page 1 of 3

Map objects to list

Posted: Fri Sep 26, 2014 10:45 am
by Lars Soligard

Hi again :)

I have a localStorageDB layer over localStorage. When i query this "db", objects are returned. Now i would really like to map these objects to a list. So far i have used:

var result = JSON.stringify(object);
Apperyio('labelName').text(result);

...Just to see that the data is being stored and that i can read the data on a different page.

But this doesn't look very nice. Could you please point me in the right direction?


Map objects to list

Posted: Fri Sep 26, 2014 1:01 pm
by Evgene Karachevtsev

Hello Lars,

[quote:]But this doesn't look very nice.[/quote]
Could you please show a screenshot of what you get and explain what you want to achieve?


Map objects to list

Posted: Fri Sep 26, 2014 2:44 pm
by Lars Soligard

Yes of course! As usual, thank you for the quick reply!

This is what it looks like:

Image

This is what i want to achieve. So in some way i need to be able to do what is normally done in the mapping, I guess? This screen is listing results from an actual database:

Image

Hope it makes sense ;-)


Map objects to list

Posted: Tue Sep 30, 2014 2:38 am
by Yurii Orishchuk

Hi Lars,

Yes it makes sens :)

Here is an a example solution for you:

1 Create generic service http://prntscr.com/434glf/direct.

2 Click "Add custom implementation"

3 Choose "new javascript" with name "genericService1JS". http://prntscr.com/434h6f/direct

4 Use following code in "JS" implementation:

pre

//Note replace "genericService1JS" with your value.
Appery.genericService1JS = Appery.createClass(null, {

Code: Select all

 init : function(requestOptions) { 
     this.__requestOptions = $.extend({}, requestOptions); 
 }, 

 process : function(settings) { 
         //Note: you need replace "yourLSV" with LSV that's stores your array. 
         var responseData = JSON.parse(localStorage.getItem("yourLSV")); 

         console.log("responseData"); 
         //Take a look on browser console to see what is stored in your LSV. 
         console.log(responseData); 

         settings.success(responseData ); 

         settings.complete('success'); 
 } 

});

/pre

After these steps you can use this service in mapping to populate your list.

Regards.


Map objects to list

Posted: Tue Sep 30, 2014 7:01 pm
by Lars Soligard

Thank's for your reply! This looks very promising. I suspected that generic service vas involved. In browser console i get this error:

"ReferenceError: Appery is not defined"

Any idea why? I've changed the name of "yourLSV" to match the name of my LSV.


Map objects to list

Posted: Wed Oct 01, 2014 2:13 am
by Yurii Orishchuk

Hi Lars,

Please try to replace "Appery" with "Apperyio" in given code.

Regard.


Map objects to list

Posted: Wed Oct 01, 2014 12:15 pm
by Lars Soligard

Thank's for the quick response! I get the same error: "ReferenceError: Apperyio is not defined"

Apperyio.genericService1JS = Apperyio.createClass(null, {
init : function(requestOptions) {
this.__requestOptions = $.extend({}, requestOptions);
},
process : function(settings) {
var responseData = JSON.parse(localStorage.getItem("fav"));
console.log("responseData");
console.log(responseData);
settings.success(responseData );
settings.complete('success');
}
});


Map objects to list

Posted: Wed Oct 01, 2014 11:32 pm
by Yurii Orishchuk

Hi Lars,

Please give us your app public link, and describe steps how we can reproduce this problem.

We will take a look.

Thanks & regards.


Map objects to list

Posted: Thu Oct 02, 2014 7:42 am
by Lars Soligard

link sendt to support, also with link to this conversation.


Map objects to list

Posted: Thu Oct 02, 2014 8:07 am
by Kateryna Grynko

Hi Lars,

Thank you! We would also appreciate if you tell how to reproduce it step by step.