Datagrid not clearing with ResetControl

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Datagrid not clearing with ResetControl

Post by Paul D » Thu Aug 06, 2009 3:56 pm

Im striking out on these datagrids.... :?

I have a mousedown handler in the last column (deleteright) behavior script. The script is supposed to delete the data from a database, clear the datagrid and repopulate. Im trying to clear the datagrid with the ResetControl command but it works in some respects and not others. It will clear everything with the empty and update buttons at the top but when I call it from the mousedown handler in my column behavior script the datagrid does not clear that column, which then wont repopulate. I uploaded the stack to revOnline under Paul D if anyone can take a look at it. :oops:

trevordevore
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1005
Joined: Sat Apr 08, 2006 3:06 pm
Contact:

Post by trevordevore » Thu Aug 06, 2009 7:59 pm

It looks like you are running into trouble because you are trying to redraw the data grid from code that is running inside one of the data grid controls.

Basically your deleteright column behavior is executing at the time when the data grid is trying to delete the control. If you want to redraw the data grid you can use send in time or move the code to the data grid itself. The lesson on how to avoid needless suffering talks about this:

http://revolution.screenstepslive.com/s ... Suffering-

Here is what your code looks like using send in time:

Code: Select all

put "recon_right" into theParam1
put theData["rightid"] into theParam2
send "deletefromdatabase theParam1, theParam2" to the dgControl of me in 0 seconds
This replaces the current code in the behavior:

Code: Select all

deletefromdatabase "recon_right", theData["rightid"]
Trevor DeVore
ScreenSteps - https://www.screensteps.com

LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder

Paul D
Posts: 116
Joined: Mon May 21, 2007 6:58 pm

Post by Paul D » Thu Aug 06, 2009 9:12 pm

"Don't call a handler that redraws the data grid from within a control in the data grid"

pretty much sounds like what i was doing, hahahaha. awesome.

thanks Trevor... and thanks for the link to that page.

Post Reply