Page 1 of 1

Whack-A-Mole datagrids

Posted: Tue Oct 14, 2014 7:28 pm
by lohill
Right now I am looking at a datagrid on a card that is showing its column headings and has a vertical scroll bars which can be scrolled up and down but no data is showing. In the message box "put the dgNumberOfRecords of group "DataGrid 1" shows that there are 110 records. However, also in the message box, 'put the dgText of group "DataGrid 1" shows nothing. Under program control with breakpoints, "put the dgText of group "DataGrid 1" into tText" shows nothing while "put the dgData of group "DataGrid 1" into tData shows all 110 elements in the array each with their 34 columns of data.

I have this kind of thing happening in a stack of four cards where then most of the buttons are part of a background common to all the cards but the datagrids (even though there are all called 'DataGrid 1') have been placed individually on each card by copying the grid from card 1 (as opposed to constructing each from scratch). The cards also have their own individual 'My Default Column Behavior' buttons (not part of background) even though they all do the same thing.

My problem is that I just finished correcting a similar problem on another card when the card I am now looking at was fine. In other words every time 'whack-a-mole', another one pops up. What am I doing wrong?

Thanks,
Larry

Re: Whack-A-Mole datagrids

Posted: Tue Oct 14, 2014 11:34 pm
by dunbarx
Hi.

Just so I am sure, you see the data when viewing the "dgData", albeit viewed in the debugger (this displays data in array form), but get nothing at all when trying to retrieve the "dgText" directly??

Are you sure you are referencing the correct group with "dgText"? Just asking. Have you tried getting the "dgData", combining it with return and tab and loading it in a big field somewhere, just to see?

It has to be something obvious.

Craig Newman

Re: Whack-A-Mole datagrids

Posted: Tue Oct 14, 2014 11:51 pm
by Simon
I wonder if this is another case of copying the data grid?
As I've heard, don't do it, always create a new data grid for each card or whatever.

Simon

Re: Whack-A-Mole datagrids

Posted: Wed Oct 15, 2014 7:00 pm
by sritcp
What Simon said.
Copying a data grid seems to cause all kinds of problems.
But copying a whole card that contains a data grid seems to work.
So, if you have an intricate data grid that you don't want to recreate, copy the card and delete the objects you don't need.

Regards,
Sri.

Re: Whack-A-Mole datagrids

Posted: Wed Oct 15, 2014 9:45 pm
by lohill
Thanks for the replies. On the one card that was showing no data even though I know it was, I deleted the datagrid and created a new one. Things seem to be OK now. For the future I think I will try Sri's suggestion of copy the whole card and then any unnecessary objects. Does anyone have an opinion on how the 'My Default Column Behavior' button should be handled? Can it safely be made a background button since it will have the same code or should there be one distinct such button on each card.

By the way, I have recently switched from using the Community edition of LiveCode to the Commercial edition. I have been using it for a few weeks and have not had the problem of not stopping at breakpoints that had me so frustrated with the Community version.

Thanks for being there,
Larry

Re: Whack-A-Mole datagrids

Posted: Wed Oct 15, 2014 9:48 pm
by lohill
That was supposed ti be 'then DELETE any unnecessary objects'.

L

Re: Whack-A-Mole datagrids

Posted: Tue Oct 28, 2014 9:47 pm
by lohill
Well I guess the problem has not been solved yet. It came up again today when I updated the data on one of the cards. Of the four cards in the stack, when the one card was updated, two others 'lost' their data. By 'lost' I mean the data was no longer visible and yet the scroll bars were showing which only happens when data is present. Interestingly enough I used the following code to fix each one and now all fout show their data.

Code: Select all

on FixGrid
   global gData
   put the dgData of group "DataGrid 1" into gData
   set the dgText of group "DataGrid 1" to empty
   set the dgData of group "DataGrid 1" to gData
end FixGrid
I am sure it was not necessary to make gData global but I didn't wast to lose the 100+ lines of data in case it did not work. I also put a breakpoint before the line 'set the dg text of group "DataGrid 1" to empty. At that point gData was populated. Another interesting thing was that by pressing the next step, it did not just go to the next step but completed the the whole routine. So many mysteries. I expect I'll see this again. I'm using LiveCode Commercial 7.0 on a Mac with Yosemite.

Larry

Re: Whack-A-Mole datagrids

Posted: Thu Oct 30, 2014 3:41 pm
by sritcp
Larry:

May be the problem is that the data grid is not refreshing the display properly?
In that case, simply sending "RefreshList" command should force a redrawing of the data grid.

Regards,
Sri.