Good morning
I have a wxGrid and a class that extends wxGridTableBase to provide the data for the wxGrid
it works as expected up to setting columns count and columns labels, adding values BEFORE view->SetTable(model); meaning that if I add two items the gui will show two items.
Once on screen, if I change the data model and call SetTable(newmodel) it will refresh the gui only when I manually change the size of the window.
I cannot find the right method to trigger that behaviour using the code
Anyone can help ?
Thank you
wxGrid plus wxGridTableBase full table refresh
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: wxGrid plus wxGridTableBase full table refresh
Did you try Refresh() ?
Re: wxGrid plus wxGridTableBase full table refresh
Yes, tried both
viewP is the pointer to wxGrid gui object
Code: Select all
viewP->GetGridWindow()->Refresh();
viewP->Refresh();
- doublemax@work
- Super wx Problem Solver
- Posts: 474
- Joined: Wed Jul 29, 2020 6:06 pm
- Location: NRW, Germany
Re: wxGrid plus wxGridTableBase full table refresh
The code must not be inside a BeginBatch/EndBatch block or with an active wxGridUpdateLocker.
If that's already the case, try topsizer->Layout() or topwindow->SendSizeEvent()
If that's already the case, try topsizer->Layout() or topwindow->SendSizeEvent()
Re: wxGrid plus wxGridTableBase full table refresh
no, the code was not in the Begin - End Batch
I ended up trying all methods that seemed reasonable and found the "right" one, so, if you want to change the data model of a wxGrid you do
from whithin the class that extends wxGridTableBase and viewP is a wxGrid instance
It would be nice to have some documentation about it, apparently, there are quite a few people looking for this information
I ended up trying all methods that seemed reasonable and found the "right" one, so, if you want to change the data model of a wxGrid you do
Code: Select all
viewP->SetTable(this);
viewP->UpdateGridWindows();
It would be nice to have some documentation about it, apparently, there are quite a few people looking for this information
Re: wxGrid plus wxGridTableBase full table refresh
Ok, status update, UpdateGridWindows actually does NOT solve the issue, but ... there is another "solution"
Rant mode on:
Can I just say that I wish ALL the "new and smart person" that comes up with some WONDERFUL idea to evaluate FIRST what has already been done before ? The pattern is as follows: "I have this new toy that solves this issue magically, you ALL must use it" and sheeple just jump on it.
python .... ahhhhhhh..... the magic snake, wonderful to write 10 lines of code and then FORGET about them. Take any minimal size application and it will be an unexploded bomb after the first week
wxWidget GUI is .... well, inventing a mostly round wheel .... whatever...
--------------- end rant mode
So, the apparent solution here is to change column width ... yes, the reason why I had a "working" solution is that I had other part of code to do a column resize when I did update the table content... and, it need to be a different value at each column, otherwise it will not work.
Can I say crap ?
Rant mode on:
Can I just say that I wish ALL the "new and smart person" that comes up with some WONDERFUL idea to evaluate FIRST what has already been done before ? The pattern is as follows: "I have this new toy that solves this issue magically, you ALL must use it" and sheeple just jump on it.
python .... ahhhhhhh..... the magic snake, wonderful to write 10 lines of code and then FORGET about them. Take any minimal size application and it will be an unexploded bomb after the first week
wxWidget GUI is .... well, inventing a mostly round wheel .... whatever...
--------------- end rant mode
So, the apparent solution here is to change column width ... yes, the reason why I had a "working" solution is that I had other part of code to do a column resize when I did update the table content... and, it need to be a different value at each column, otherwise it will not work.
Can I say crap ?
Re: wxGrid plus wxGridTableBase full table refresh
some more info on having a table refresh when changing data source
the colSize you are going to set must be different than the default, otherwise the magic will not work
Can I say that there should be a method for wxGrid refresh and one for wxRow refresh ?
Code: Select all
const int defColsize = GetDefaultColSize();
Can I say that there should be a method for wxGrid refresh and one for wxRow refresh ?
Re: wxGrid plus wxGridTableBase full table refresh
I am not really familiar with wxGrid, so I am not even sure you can change its table, since SetTable() docs say (emphasis mine).
Either way, if you have a feature suggestion or a bug report, I recommend using wx-dev discussion group since that is the place where you can reach the developers.
See also https://github.com/wxWidgets/wxWidgets/pull/22826
Be that as it may, I assume you tried not only wxGrid::RefreshBlock() but also wxGrid::ForceRefresh() (this one should be used instead of Refresh()) but neither worked?This should be called after the grid constructor and before using the grid object.
Either way, if you have a feature suggestion or a bug report, I recommend using wx-dev discussion group since that is the place where you can reach the developers.
See also https://github.com/wxWidgets/wxWidgets/pull/22826