Create list from database

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

I am having some issues in creating a list from a database.

I am loading a layout in a panel, based on if there is text in a field in my database. (there could be about 250 fields I need to display, but in my attached example I have made it 200)

So if the field in my database is blank (no text) then it will skip and move onto the next one. If it isn't blank (has something in the field) then it should load the layout in the panel and display it on the screen.

However when I am doing this it is taking about 2-3 seconds to show it on the screen.

The less items with names the faster it loads. So I am guessing it is taking some time to create/add the layout to the page?

Is there a better way to do this or is there a way to make it faster?

I have attached the code I am using hoping someone can help.
 

Attachments

  • Demo.zip
    73 KB · Views: 289

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is not related, however you should declare SQL objects as process global variables and only initialize them when FirstTime is true.

The problem is that you are creating many views. Switching to TableView will make it significantly faster.

You can also try to create the rows layout by code. It will be faster than loading the layout file 200 times.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
hello,

You can also try to create the rows layout by code. It will be faster than loading the layout file 200 times.

do you mean using .addview? as I have tried that and it was no faster.

Switching to TableView will make it significantly faster

is a TableView going to allow me to create something like below (as that is what I am trying to do) or is that more of a list with multiple columns?

wR2as.png
 
Upvote 0

Eduard

Active Member
Licensed User
Longtime User
Hello,
So if the field in my database is blank (no text) then it will skip and move onto the next one. If it isn't blank (has something in the field) then it should load the layout in the panel and display it on the screen.
Why fetch this field from database if it doesn't need to be displayed?

However when I am doing this it is taking about 2-3 seconds to show it on the screen.
If you do a 'DoEvents' after each record than it will be a little bit slower, but it will appear to be faster for the user because the list will be directly visible and scrollable.

Also: is it necessary to load all the records? You could load the records that are visible by the user. You can use scrollposition to determine what part of the list is actually visible and load only these.
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Hello,

Why fetch this field from database if it doesn't need to be displayed?

I need to fetch this field from the database, as if I don't then I won't know if there isn't any data in there. (if I knew there was no data in the field then I can load the list a lot faster as I would know which ones to load and which ones not to load.)

To speed the page load, I might need to load the first 10 or 20 as that is all you can see on the page before you need to scroll down the page, and once the page is loaded then get the rest of the database.

Sounds like I need to play around with it or think of another way to do display my data / list.
 
Upvote 0
Top