DataGrid / UI does not update consistently [Solved?]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
DataGrid / UI does not update consistently [Solved?]
Hi all,
I have the problem that a Datagrid does not update consistently during the running of a loop. Sometimes it does and sometimes I just see a bussy Cursor icon and it only updates after the loop has finished.
It seems to be depending on the number of updates and the time between the adding or changing of a line in the datagrid. When there are many updates in a short time I only see the busy cursor and the Datagrid only updates at the end of the loop, and when there are fewer updates it updates the Datagrid with every added or changed line.
Any idea's how to solve this without significantly slowing down the loop?
Kind regards,
Paul
I have the problem that a Datagrid does not update consistently during the running of a loop. Sometimes it does and sometimes I just see a bussy Cursor icon and it only updates after the loop has finished.
It seems to be depending on the number of updates and the time between the adding or changing of a line in the datagrid. When there are many updates in a short time I only see the busy cursor and the Datagrid only updates at the end of the loop, and when there are fewer updates it updates the Datagrid with every added or changed line.
Any idea's how to solve this without significantly slowing down the loop?
Kind regards,
Paul
Last edited by mrcoollion on Fri Feb 18, 2022 9:50 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: DataGrid does not update consistently
How do you update? Do you:
Craig
Code: Select all
dispatch "ResetList" to group "yourDataGrid"
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: DataGrid does not update consistently
Hello Craig,
For adding a line I use:
For updating a line I use:
Regards,
Paul
For adding a line I use:
Code: Select all
put tNewPositionNbr into theLineNo
dispatch "AddData" to group "DG_SimulatedTrades" with theDataA, theLineNo
For updating a line I use:
Code: Select all
set the dgDataOfLine[tPositionNbr] of group "DG_SimulatedTrades" to pDataA
Paul
Re: DataGrid does not update consistently
Hi Paul,
I think Craig was giving you the answer rather than asking a question
Personally if updating single lines, i'd call refreshLine after updating data or adding data:
If you're doing a whole lot of updates, i'd use something like what Craig says instead of refreshing individual lines, but my preference is using refreshList to update the whole data grid instead:
In other words, after running your loop changing multiple records, call this at the end.
hope that helps,
Stam
I think Craig was giving you the answer rather than asking a question
Personally if updating single lines, i'd call refreshLine after updating data or adding data:
Code: Select all
dispatch "RefreshLine" to group "DataGrid" with pLines
Code: Select all
dispatch "RefreshList" to group "DataGrid"
hope that helps,
Stam
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: DataGrid does not update consistently
Stam reads me like a book.
I wish I did.
But, Stam, what is different between your post and mine?
Craig
I wish I did.
But, Stam, what is different between your post and mine?
Craig
Re: DataGrid does not update consistently
Not much in real terms i suspect. Some theoretical differences:
ResetList redraws the data grid data after having copied in fresh copies of any templates. Potentially a bit slower as it's reloading text, graphics, templates, layouts etc. Overkill for the OP's purpose as well...
RefreshList redraws the data displayed in the data grid. Potentially faster as it only refreshes the data.
RefreshLine redraws the data only for the specified line - potentially much fast if you're only changing the one line.
In real terms and especially for smaller data grids there is probably no noticeable difference between resetList and refreshList - but given that there is a speed penalty using the data grid anyway (compared to a table field for example) it makes me feel just a little bit better thinking i am eeking just a bit more speed out of the data grid
-
- VIP Livecode Opensource Backer
- Posts: 9655
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: DataGrid does not update consistently
Stam.
Ah, thanks. As I am fond of saying, "I use data grids, but do not understand them".
Craig
Ah, thanks. As I am fond of saying, "I use data grids, but do not understand them".
Craig
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: DataGrid does not update consistently [Solved?]
Tried multiple solutions like
It seems that the UI lockes while running a repeat loop that goes through a few thousand iterations.
To prevent this I placed the following line at the beginning of the repeat loop and that worked.
I thought this issue did not exist anymore (as of LC 7) but it seems it still does.
It does not make the loop significantly slower so all is well now
Thanks for all the suggestions/help. Truly appreciate it.
Regards,
Paul
Code: Select all
dispatch "RefreshList" to group "DG_SimulatedTrades"
Code: Select all
set the backgroundColor of this card to the backgroundcolor of this card // Refresh screen
To prevent this I placed the following line at the beginning of the repeat loop and that worked.
Code: Select all
wait 0 with messages // To stop UI from freezing
It does not make the loop significantly slower so all is well now
Thanks for all the suggestions/help. Truly appreciate it.
Regards,
Paul
Re: DataGrid / UI does not update consistently [Solved?]
Hi Paul, are you trying to refresh data in the middle of your loop?
If you are you probably shouldn’t… just run refreshList after the loop has completed and it should just refresh the data…
If you are you probably shouldn’t… just run refreshList after the loop has completed and it should just refresh the data…
-
- Posts: 720
- Joined: Thu Sep 11, 2014 1:49 pm
- Location: The Netherlands
Re: DataGrid / UI does not update consistently [Solved?]
You Are correct, I am refreshing the data during the loop. This is necessary to show the user what is happening during the loop. With the 'wait 0 with messages' command it works fine.
Thanks