Hi,
I have a menu button which should delete selected rows from grid.
Here is my code in OnClick event:
foreach (Row selectedRow in xGrid.SelectionSettings.SelectedRows)
{
xGrid.Rows.Remove(selectedRow);
}
This code removes only last selected row which has a selector triangle on left. Other rows remain untouched. What is wrong here?
Thank you.
Thank you for reply.
Yes I know about Delete key and I use it already but my boss says "if there is a toolbar, there must be a big red button on it" :)
I will try your code, thank you.
So when Remove is called it triggers the xamWebGrid to refresh itself, which happens in an async manner, so when you call remove any time after that, its actually not removing anything.
Instead, you need to use RemoveRange. However, we didn't make that method public, which is why you can't see it in your intellisense. I will however be correcting this, as it was an oversight.
However, luckily, the RemoveRange method is still exposed via the RowsManager, which you can access, so here is some code that will do the trick for you in the mean time.
((Infragistics.Silverlight.IProvideDataItems<Row>)xamGrid.Rows[0].Manager).RemoveRange(xamGrid.SelectionSettings.SelectedRows);
Also, just to let you know, we offer delete functionality via the delete key, which can be turned on using the DeleteKeyAction property on the xamWebGrid.
-SteveZ