Delete a row in a data grid?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Delete a row in a data grid?
Does anyone know how to delete a row in a data grid? With a plain old field, you could set a mouseup to get the line number of a click and then do "delete line...of me."
I understand how to get the row number when you click on a data grid using "dgline of me." But then what?
Thanks.
(By the way, I absolutely love data grids. It's made a night-and-day improvement in the presentation of information in a current project.)
I understand how to get the row number when you click on a data grid using "dgline of me." But then what?
Thanks.
(By the way, I absolutely love data grids. It's made a night-and-day improvement in the presentation of information in a current project.)
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Take a look at DeleteIndex and DeleteLine in the Data Grid API. Those should do what you need.[/url]
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
Thanks for the help. Deleteindex works like a charm except for one little wrinkle. I can delete but not if the data grid only contains one row. Put another way, I can keep deleting rows one after the other using the following lines except when there is only one row left. Any solution? Thanks.
put the dgindex of me into tLine
put "deleteindex " & tLine into tCutRow
send tCutRow to group "DataGrid1"
put the dgindex of me into tLine
put "deleteindex " & tLine into tCutRow
send tCutRow to group "DataGrid1"
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Where is the script? Who "of me" is could affect the behavior. Try this in the data grid group script. It works for me.
Code: Select all
on deleteKey
put the dgHilitedIndex of me into theIndex
DeleteIndex theIndex
end deleteKey
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
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Hmm, have you been editing the data grid scripts at all? Does it work if you quit and restart Rev? If neither of the above then can you send a stack to me?
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
Trevor, I'm having the same problem as the original poster. Your method of using the Delete key does work correctly.
But what I'm trying to do is put a small Delete button inside the datagrid (form) so that it appears on each populated row of the grid. I then put code inside that button:
This works fine for every row except if there is only one row left in the grid in which case the row won't delete. Actually, I think the row is deleted in the background but it visually remains in the grid until the form is closed and reopened.
Please let me know if that makes no sense and I can send a small sample. Thanks.
... Ron
But what I'm trying to do is put a small Delete button inside the datagrid (form) so that it appears on each populated row of the grid. I then put code inside that button:
Code: Select all
on mouseUp
put the dgHilitedIndex of me into theIndex
DeleteIndex theIndex
end mouseUp
Please let me know if that makes no sense and I can send a small sample. Thanks.
... Ron
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Try one of two things:
a) Use send in time to delete the index so that the data grid doesn't try to delete the button that is calling "DeleteIndex".
b) Put the mouseUp in the data grid control and check if the target is the button that should perform the delete.
a) Use send in time to delete the index so that the data grid doesn't try to delete the button that is calling "DeleteIndex".
Code: Select all
send "DeleteIndex theIndex" to the dgControl of me in 0 seconds
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