Page 1 of 1
Delete a row in a data grid?
Posted: Tue May 12, 2009 12:00 am
by akazakana
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.)
Posted: Tue May 12, 2009 2:11 pm
by trevordevore
Take a look at DeleteIndex and DeleteLine in the
Data Grid API. Those should do what you need.[/url]
Posted: Tue May 12, 2009 3:13 pm
by akazakana
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"
Posted: Tue May 12, 2009 3:18 pm
by trevordevore
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
Posted: Tue May 12, 2009 3:33 pm
by akazakana
No dice, I'm afraid. Using the code you suggested, I can hilite the remaining row but still can't delete it.
Posted: Tue May 12, 2009 3:48 pm
by trevordevore
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?
Posted: Tue May 12, 2009 5:26 pm
by akazakana
I tried restarting but that didn't work. It's just a minor matter at this point, so I'll take you up on your offer of sending a stack when it's a bit more presentable if I may.
Thanks for all the help.
Posted: Tue May 19, 2009 1:05 am
by ronn
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:
Code: Select all
on mouseUp
put the dgHilitedIndex of me into theIndex
DeleteIndex theIndex
end mouseUp
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
Posted: Tue May 19, 2009 1:50 am
by trevordevore
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".
Code: Select all
send "DeleteIndex theIndex" to the dgControl of me in 0 seconds
b) Put the mouseUp in the data grid control and check if the target is the button that should perform the delete.
Posted: Tue May 19, 2009 3:05 am
by ronn
Ta da!! Both of the suggested methods worked for me. Thanks very much Trevor.
... Ron