Chris7483339
Posts: 0
Joined: Tue Apr 14, 2015 5:19 pm

Can a list item have variables?

I have a number of date objects stored in a database and I'm pulling them from there into a list using Appery's built in looping. I've got a little bit of Javascript that changes the format of the date to a more user friendly string that is then mapped to the Text attribute of the Mobile List Item. I also want to take the ID of each date object returned from the database and store it in the List Item somehow, so that I can make use of it when that item is clicked on. Is there a way that I can specify some property for each List Item that I can use to store this ID?

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Can a list item have variables?

Chris,

In your UI - you are likely using a grid object to format the output from the list (or you could). What I do - and what the tutuorials do I believe - is in the same grid cell as the first and only item of the list - I drop a label element below the list item.

Change the properties of the label element from visible to not visible (turn the checkbox off for 'visible').

In the builder - map the ID to the label text... thus storing the ID in the label text - which however is NOT visible.

In the click event 'for the grid line' - set a local storage variable to the text value of the label text. You can then - in subsequent events (the same click event) - use the saved localStorage value - to do things like navigate to a new page - where you edit or show the item just clicked on.

If this all sounds a bit Greek to you - let me know - I can send along visuals and code from my builder.

best,

bruce

Chris7483339
Posts: 0
Joined: Tue Apr 14, 2015 5:19 pm

Can a list item have variables?

Hi Bruce.

Thank you very much for your reply, it helped me greatly! I've done what you've suggested and it works fine, my only issue is to do with presentation.

I've mapped $ from my response to the mobilegrid item so it makes a new 1x2 grid for each date returned from the database. I'd like to map it to a grid cell, rather than the grid itself, so that I end up with one grid with multiple rows, instead of having multiple grids. Unfortunately the cells don't appear on the mapping screen - just the grid as a whole.

Is there a way around this?

Thanks again

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

Can a list item have variables?

Hi Chris,

I'm not precisely sure how you've accomplished your end state without a few more details. As you likely know - it's a very common scenario. Here's how I've dealt with the same challenge in a simple app that lists classes that are available.

let me know if this doesn't help...

Some things to note ---- on the first UI below - I've shown my UI design - of note the grid is where the data items are showing - but below the grid - but still on the list item - I've dropped my label item - and set it as not visible.

In the second UI - i've shown the mapping of the listItem id to the localStorage var.

In the 3rd UI - I've shown my mappings.

In the 4th UI - how the UI looks in the tester (note - no second line....).... let me know if I've missed something here - and this doesn't help you.

Best,

Bruce

Image

Image

Image

Image

Return to “Issues”