Best way to create a data grid / table?

Discussion and feedback on Construct 2

Post » Thu Mar 13, 2014 5:56 am

hi guys,

trying to create a data grid - type table in C2 and was wondering if anyone had already done this or could point me in the right direction.

i'm creating a multiplayer game with a "game lobby", with a long table of data fetched from a database to display 100+ rows of "open games" that users can join.

i have all the database functions completed and working, i can test load data using the text objects, but I will need a solution for a future of 100+ rows.

what is the best way to display rows of data in C2?
B
4
G
1
Posts: 19
Reputation: 353

Post » Fri Mar 14, 2014 8:23 am

I usually make a function that reads the data from an array with loopindex-ed position.
Or you can use the board plugin:
viewtopic.php?t=69647&start=0
Image
B
71
S
28
G
12
Posts: 515
Reputation: 12,284

Post » Fri Mar 14, 2014 7:48 pm

@rainmaker, I once programmed a solution like this, using text objects as well!

What you do is, instead of creating 10000000 text objects for a big table, create only as many as the user can see at once, then add a scrollbar to the side.

When the user scrolls, instead of scrolling the layout as you would do normally, just make the source text for each line advance by one.

Say your source data is a list of fruits:
[1] - Banana
[2] - Apple
[3] - Orange
[4] - Watermelon
[5] - Pineapple
[6] - Grape
[7] - Blueberry

And the user can see 3 lines at most
Line 1 -> fruits[1]
Line 2 -> fruits[2]
Line 3 -> fruits[3]

Now say the user scrolls 1 item down. Instead of seeing "Line 4", the lines themselves don't change, just the references:
Line 1 -> fruits[2]
Line 2 -> fruits[3]
Line 3 -> fruits[4]

This way, the objects remain fixed, nothing new is created, just their text is changed! The only downside is the scrolling appears less smooth, since you can't scroll down, say, "10 pixels. You must scroll in whole lines.
B
36
S
8
G
8
Posts: 532
Reputation: 6,903

Post » Sat Mar 15, 2014 9:40 pm

Fimbul wrote:@rainmaker, I once programmed a solution like this, using text objects as well!

What you do is, instead of creating 10000000 text objects for a big table, create only as many as the user can see at once, then add a scrollbar to the side.

When the user scrolls, instead of scrolling the layout as you would do normally, just make the source text for each line advance by one.

Say your source data is a list of fruits:
[1] - Banana
[2] - Apple
[3] - Orange
[4] - Watermelon
[5] - Pineapple
[6] - Grape
[7] - Blueberry

And the user can see 3 lines at most
Line 1 -> fruits[1]
Line 2 -> fruits[2]
Line 3 -> fruits[3]

Now say the user scrolls 1 item down. Instead of seeing "Line 4", the lines themselves don't change, just the references:
Line 1 -> fruits[2]
Line 2 -> fruits[3]
Line 3 -> fruits[4]

This way, the objects remain fixed, nothing new is created, just their text is changed! The only downside is the scrolling appears less smooth, since you can't scroll down, say, "10 pixels. You must scroll in whole lines.


I like your solution, thanks for share :)
B
17
S
5
G
2
Posts: 173
Reputation: 2,085

Post » Sun Mar 16, 2014 2:08 am

Fimbul wrote:@rainmaker, I once programmed a solution like this, using text objects as well!

What you do is, instead of creating 10000000 text objects for a big table, create only as many as the user can see at once, then add a scrollbar to the side.

When the user scrolls, instead of scrolling the layout as you would do normally, just make the source text for each line advance by one.

Say your source data is a list of fruits:
[1] - Banana
[2] - Apple
[3] - Orange
[4] - Watermelon
[5] - Pineapple
[6] - Grape
[7] - Blueberry

And the user can see 3 lines at most
Line 1 -> fruits[1]
Line 2 -> fruits[2]
Line 3 -> fruits[3]

Now say the user scrolls 1 item down. Instead of seeing "Line 4", the lines themselves don't change, just the references:
Line 1 -> fruits[2]
Line 2 -> fruits[3]
Line 3 -> fruits[4]

This way, the objects remain fixed, nothing new is created, just their text is changed! The only downside is the scrolling appears less smooth, since you can't scroll down, say, "10 pixels. You must scroll in whole lines.




Awesome!! I figured it would be something like that. Thanks a lot!
B
4
G
1
Posts: 19
Reputation: 353

Post » Sun Mar 16, 2014 2:39 am

@rainmaker, the iScroll plugin can do this -- its a pretty rich HTML formatted scrollable table to!

viewtopic.php?f=153&t=66289&p=752112&hilit=iscroll#p752112

Downside, the author doesn't have time to fix any issues you may find, however, it's worth checking out.
B
71
S
14
G
1
Posts: 151
Reputation: 4,974

Post » Sun Mar 16, 2014 8:42 am

remy-jay wrote:@rainmaker, the iScroll plugin can do this -- its a pretty rich HTML formatted scrollable table to!

viewtopic.php?f=153&t=66289&p=752112&hilit=iscroll#p752112

Downside, the author doesn't have time to fix any issues you may find, however, it's worth checking out.

Awesome, I'm going to test this plugin :)
B
17
S
5
G
2
Posts: 173
Reputation: 2,085


Return to Construct 2 General

Who is online

Users browsing this forum: Cliffu, Mayfly and 1 guest