Datagrid DeleteLine Problem
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Datagrid DeleteLine Problem
I'm calling DeleteLine from a handler in the group script of a datagrid. The line gets deleted from the datagrid's data (verified with send printkeys), but is still displayed in the datagrid until I issue another call that redraws the datagrid, eg sort.
ANy ideas?
Pete
ANy ideas?
Pete
Re: Datagrid DeleteLine Problem
Check out this page. http://revolution.screenstepslive.com/s ... Suffering-
if you change your deleteline to a send in time as in the first example on that page it should start working.
if you change your deleteline to a send in time as in the first example on that page it should start working.
Re: Datagrid DeleteLine Problem
After debugging this further, the problem only occurs when there is only 1 line of data in the datagrid and I try to delete that line. At Trevor Devore's suggestion, I wrapped the DeleteLine in a try block and got the following dump in the message box (the first line came from a put in my code).
error 347,0,0
76,3380,13
144,3380,1
490,3379,1
490,3374,1
241,3374,1,_table.DeleteDataControls
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,2169,1
587,2167,1
241,2167,1,_DeleteDataControls
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1907,1
241,1907,1,_ResetData
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1304,1
253,1301,1
241,1301,1,DeleteIndexes
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1230,1,DeleteIndexes
241,1230,1,DeleteLines
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1216,1,DeleteLines
241,1216,1,DeleteLine
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,3,1,DeleteLine
error 347,0,0
76,3380,13
144,3380,1
490,3379,1
490,3374,1
241,3374,1,_table.DeleteDataControls
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,2169,1
587,2167,1
241,2167,1,_DeleteDataControls
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1907,1
241,1907,1,_ResetData
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1304,1
253,1301,1
241,1301,1,DeleteIndexes
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1230,1,DeleteIndexes
241,1230,1,DeleteLines
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,1216,1,DeleteLines
241,1216,1,DeleteLine
353,0,0,button id 1005 of group id 1004 of card id 1002 of stack "/Applications/Revolution Studio/4.0.0-gm-1/Toolset/revdatagridlibrary.rev"
573,3,1,DeleteLine
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid DeleteLine Problem
You mentioned that DeleteLine is called from a handler in your group script but is the handler in your group script called from an event handler in your behavior script?
I would try sturgis' suggestion.
I would try sturgis' suggestion.
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
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
Re: Datagrid DeleteLine Problem
Here's the chain of events.
The card has a popup menu button on it which is displayed when the user clicks the right mouse button over a line in the datagrid (I followed all the instructions about dealing with mouseUp in a datagrid). One of the options in the popup menu is to delete the currently selected line. The popup menu menuPick script calls the handler that is in the datagrid group script which includes the DeleteLine command. I did it that on purpose as I thought having the DeleteLine call in the datagrid group script would work without using the send trick.
I tried the send trick and it appears to have fixed the issue. However, I'd really like to understand what's going on behind the scenes so have a couple of questions.
From the description I've given of where the DeleteLine call is issued, should this work without the send? This will help me code things correctly in the future.
Why does the problem only occur if there is only one line of data in the datagrid?
Thanks,
Pete
The card has a popup menu button on it which is displayed when the user clicks the right mouse button over a line in the datagrid (I followed all the instructions about dealing with mouseUp in a datagrid). One of the options in the popup menu is to delete the currently selected line. The popup menu menuPick script calls the handler that is in the datagrid group script which includes the DeleteLine command. I did it that on purpose as I thought having the DeleteLine call in the datagrid group script would work without using the send trick.
I tried the send trick and it appears to have fixed the issue. However, I'd really like to understand what's going on behind the scenes so have a couple of questions.
From the description I've given of where the DeleteLine call is issued, should this work without the send? This will help me code things correctly in the future.
Why does the problem only occur if there is only one line of data in the datagrid?
Thanks,
Pete
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid DeleteLine Problem
In the current version of the data grid library, the data grid wipes all controls out when you delete the last line. This is what causes the error and why the send is required (you are effectively deleting the control that is processing an engine message, mouseup in this case).
Rev 4.5 will no longer have this limitation. The data grid behavior has been updated so that the send trick will no longer be required.
Rev 4.5 will no longer have this limitation. The data grid behavior has been updated so that the send trick will no longer be required.
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
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
Re: Datagrid DeleteLine Problem
Great, thanks Trevor.
Pete
Pete
Re: Datagrid DeleteLine Problem
OK, well I guess I spoke to soon. Heres what happens now with the send trick in place.
If there is only 1 line in the datagrid and I delete it, all works just fine.
If there is more than one line in the datagrid and I delete any line except the first one, the line still shows in the datagrid even though printkeys shows it is no longer in the datagrid. That's what was happening before I switched to using the send trick. If I delete the first line, it is removed form the datagrid display, but the display of what is now the first line looks like it's a combination of the current first line plus the one I just deleted.
EDIT----
OK, never mind. I just noticed that I had SHow Invisible Objects switched on. With that off, everything works fine. Which I guess does lead me to ask if the datagrid display does include hidden objects?
END OF EDIT---
Pete
If there is only 1 line in the datagrid and I delete it, all works just fine.
If there is more than one line in the datagrid and I delete any line except the first one, the line still shows in the datagrid even though printkeys shows it is no longer in the datagrid. That's what was happening before I switched to using the send trick. If I delete the first line, it is removed form the datagrid display, but the display of what is now the first line looks like it's a combination of the current first line plus the one I just deleted.
EDIT----
OK, never mind. I just noticed that I had SHow Invisible Objects switched on. With that off, everything works fine. Which I guess does lead me to ask if the datagrid display does include hidden objects?
END OF EDIT---
Pete
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: Datagrid DeleteLine Problem
A data grid hides rows controls if no data is being displayed in them. Those would show up if you have show invisibles turned on.
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
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
Re: Datagrid DeleteLine Problem
Got it, makes sense.