Simon Hutchinson
Posts: 0
Joined: Thu Jun 13, 2013 11:18 am

Way to display lots of database data

Hi all,

I've been going through the tutorial on databases and have managed to successfully connect up to my app a database and read data out (as well as post, that is working fine no issues)

The issue i have is i am finding it difficult to bring the data through in a nice way. I have a database which in each entry holds about five fields.

If i use the mapping tool on the list object it only brings through the last item i map if i map all the fields

How can i loop through the database and display all the entries with all the fields in a nice format? One way i've tried is just to have a whole bunch of labels but that only shows the most recent entry (as i can't loop the array through the label like you can a list).

Thanks in advance

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Way to display lots of database data

hi,

If you have the labels in the List component or something, you'd all need to map the array to the List Component. If you can post a picture of your mapping, then perhaps I can suggest what's wrong.

Cheers,
M&M

Simon Hutchinson
Posts: 0
Joined: Thu Jun 13, 2013 11:18 am

Way to display lots of database data

Thanks for your response

mapping is here

http://snag.gy/xsHud.jpg

Simon Hutchinson
Posts: 0
Joined: Thu Jun 13, 2013 11:18 am

Way to display lots of database data

as you can see i have multiple db fields assigned to the one UI item

im trying to get it to be like

Name, Team, ID, etc etc

Simon Hutchinson
Posts: 0
Joined: Thu Jun 13, 2013 11:18 am

Way to display lots of database data

I've been playing some more and i think i have to revisit my idea so this is what i need some help with now.

As you can see there is multiple data fields i need to display

As these are DB entries i was thinking of now having a page per entry (up to latest 10 entries) that lists the data in labels

for example

Name:
Team:
Id: Team
etc

and then at the bottom buttons to move thorugh the records

The big thing im trying to solve with this is how do i sort database records. so for example on page 2 i want to show the 2nd most recent record.

Hope i have explained this ok

Cheers

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Way to display lots of database data

For a test / to narrow in on the problem what if you just map only the name to the name field and run the app. Does it show all the records?

As for the mapping of all fields to one component / label - I think it's probably overwriting the previous value - unless you have handled it in some way in the JS. Can I have a screenshot of that is the result that you see? I think you are almost there except for some small mistake

Cheers,
M&M

Simon Hutchinson
Posts: 0
Joined: Thu Jun 13, 2013 11:18 am

Way to display lots of database data

Hi

thanks for your help

Yes if i map name only it does show all records it just seems i can't have the data in one line.

And yes i believe you are correct that its overwriting it :) The one i added last to the object is the one that is displayed on the screen.

I'm not sure im going to be able to have all the data on one line?. How could i make it that each list item becomes a link to a new page with all the data from that db entry?

or failing that do you know how to pull out a specific record in a database that is not necessarily a query based on the data inside it. For example a query to get the 2nd most recent DB entry regardless of the data within? That would allow me to get what i want with a bit of a workaround.

Cheers

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Way to display lots of database data

hi,

So this is how you'd achieve this. This is the Design where I have a collection with fields like Salutatio, Name, Age...and I am displaying this records in a list Item. And one of the fields is a combination / concatenation of Salutation + space + Name...for example Mr. John....or Mr. Susan

Image Image

The above is the result. One way to achieve this would be to add a mapping as shown in this picture

Image

And for the JS for that field just add this code.
Image

Here is the code in case you'd want to copy/paste and test

var NameAndSalutation = element.find('[name="lblCityState"]');

var NameAndSalutationConcatenated = value.Salutation + " " + value.Name;
NameAndSalutation.text(NameAndSalutationConcatenated);
return value;

That should work.

Cheers,
M&M

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Way to display lots of database data

hi,

So this is how you'd achieve this. This is the Design where I have a collection with fields like Salutation, Name, Age...and I am displaying this records in a list Item. And one of the fields is a combination / concatenation of Salutation + space + Name...for example Mr. John....or Mr. Susan

Image

The result would be
Image

You will have to map it this way: with the JS
Image

Here is the JS code just in case you wish to copy / paste / test
var NameAndSalutationConcatenated = value.Salutation + " " + value.Name;

var NameAndSalutation = element.find('[name="lblSalutationName"]');
NameAndSalutation.text(NameAndSalutationConcatenated);
return value;

Cheers,
M&M

M&M
Posts: 0
Joined: Tue Nov 11, 2014 6:59 am

Way to display lots of database data

And ya the mapping goes this way

Image

Cheers,
M&M

Return to “Issues”