doubletake
Posts: 0
Joined: Sat May 25, 2013 5:55 pm

More Properties in service mapping?

In your list examples, you have to replace a list item with a hidden label if you want to pass an ID. This removes the JQueryMobile list item style. (since it is no longer a Li ).

I'd like to pass the studentID in something other than a hidden Label component so I can keep using Li. Are there any other options to do this?

My preference would be able to map the studentID to a "More Properties" item called "data-studentID". But, these additional properties do not show up in the edit mapping view. This way, when the list item is selected, I can set the localStorage using the value of data-studentID.

Thanks,
Don

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

More Properties in service mapping?

Hi - we will try to find a workaround for that. We'll update.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

More Properties in service mapping?

When you do mapping, you can add JavaScript to it. Two objects are passed to the mapping function: value, element.

'element' - is the jQuery Mobile component to which you are mapping. You could run any code there.

http://docs.appery.io/documentation/a...

doubletake
Posts: 0
Joined: Sat May 25, 2013 5:55 pm

More Properties in service mapping?

Max,
Sorry but I'm not getting how this helps me with my issue?

I need to display the Student Name in the list item, yet also pass in the studentID to the list item.

When the studentName is selected, I need to save the studentID to localStorage for my studentDetails service call.

currently Set Local Storage requires a property of the component to be used.

Maybe I just need to see an example of how map studentID and studentName to the same Li.

Thanks,
Don

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

More Properties in service mapping?

Let's say you added a custom attribute to a list item called "data-studentId". To know which item you clicked on, use Click/Run JavaScript action. You will have access to the current item clicked on. Then find the "data-studentId" attribute in the current (this) node and save it into local storage.

doubletake
Posts: 0
Joined: Sat May 25, 2013 5:55 pm

More Properties in service mapping?

I get that part. However, the service mapping doesn't let me map the studentID value in the result to data-studentID. How do I set this value for each item in the loop?

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

More Properties in service mapping?

In mapping for the collection (root) itself, you could access that JSON response and get any value from it.

doubletake
Posts: 0
Joined: Sat May 25, 2013 5:55 pm

More Properties in service mapping?

Max, I got this to work:

In the "loop" mapped list item, I added JS to copy the value object into a custom "data-mydata" property of the current list item element.

$(element).attr('data-mydata',JSON.stringify(value) );
//console.log($(element).attr('data-mydata'));

Then, in the list item click event I grab the object
var o = jQuery.parseJSON( $(this).attr('data-mydata') );

using the data-mydata attr allows me to pass the addition properties I need without having to create a hidden labels, etc. to pass the data in.

I just got used to binding ArrayCollections to lists in Flex and then having access to all the selectedItem's properties.

I guess I just couldn't find the "value" object inside the "element", so I had to copy it there. This works well for me. But, let me know if there is a more efficient way.

Appreciate the help.
Don

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

More Properties in service mapping?

This works.

Return to “Issues”