I try to delete a record from an ultragrid with this two examples:
(1)
ultragrid1:rows:Item[5]:Delete()
(2)
ultragrid1:rows:Item[10]:Selected = true
ultragrid1:DeleteSelectedRows(false).
In both cases the last record in the ultragrid is deleted. When I select two records with the Selected method, then the last two records in the ultragrid are deleted. Somewhere the recordsscope is lost, the delete method points to the wrong record. Can anybody help me?
ThijsSchoemaker said:When I select two records with the Selected method, then the last two records in the ultragrid are deleted
Thanks for your response. What I want to do is point a record in the browse by setting the Selected property to true and and then I want to delete this record.
This is the (OpenEdge) code I use for it:
define variable i as integer.grid_2:rows:Item[3]:Selected = true. do i = 0 to grid_2:rows:Count - 1: if grid_2:Rows:item[i]:Selected = true then grid_2:Rows:item[i]:delete().end.
However, everytime I call the delete method, it deletes the last record from the browse. It have tried to use the UltraGrid.Selected.Rows collection, the DeleteSelectedRows method or the normal delete statement to delete the record I want, but still without the right result. I have installed the UltraWinGrid v 9.1
Hi,
I'm not at all familiar with OpenEdge, but this works just fine for me in visual Studio. It sounds to me like this might be a problem with the grid's DataSource. What kind of DataSource are you using?
Are you getting a prompt asking you to confirm the deletion?
Just as a test, you might try handling the BeforeRowsDeleted event and see if the event is firing, and if so, what rows are passed into the event args.
Thanks for your repsond. Can you show a code-example how to get a specific row? When I try e.ToString in the BeforeRowsDeleted then it returns Infragistics.Win.UltraWinGrid.UltraGridRow[] and I don't know how the read this row more detailed.
However, I think that this will result in the following: it gives the last record and deletes it. I am looking for a property called Grid.LinkToSourceOnDelete that points to the right record when there is a delete trigger.
Regards, Thijs
e is the event arguments. It has a property called Rows on it which gives you a collection of the rows that are about to be delete. So you probably want to do something like this:
private void ultraGrid1_BeforeRowsDeleted(object sender, BeforeRowsDeletedEventArgs e) { foreach (UltraGridRow row in e.Rows) { Debug.WriteLine(row.Cells["My id column"].Text); } }
There's no property to link to any source rows, because such a property would be redundant. The grid already handles deleting the correct rows.
Maybe I am doing something wrong, I'm quitte a newbe to Infragistics. Anyway, thanks for the help.
Ok, thanks for your help, Thijs!
I have also post this issue on Progress Communities. Up til now I get only reactions that confirm the described behaviour. Its probably a bug in OpenEdge 10.2A and 10.2B. When I have found a proper solution I will post it here!
Thijs
Thijs, did you find a solution? I'm having the exact same problem at the moment. Using OpenEdge (Architect) 10.2A02 with Infragistics NetAdvantage for .NET v2008 Vol 1 CLR 2.0.