I have a checkbox for all rows in the grid. I want the user to be able to delete multiple rows by selecting as many as they want and then hit "delete." Kind of like email in Gmail/Yahoo, etc.
I have two issues.
One, I get a warning for every row that the user tries to delete. Can I suppress this warning? I can't find the setting anywhere.
Two, when the last row tries to delete in my foreach loop, I get an error:
InvalidaOperationException... Any idea what's going on here and how to fix this? It happens on the last selected is to be deleted... Please let me know your thoughts. I seearched the forums and couldn't find anything.
In case anyone wanted to see my code:
public static void RemoveSelected(string columnKey, JWWinGrid grid) { foreach (UltraGridRow row in grid.Rows) { if ((bool)row.GetCellValue(grid.Columns[columnKey])) { row.Delete(); } } }
Okay, found the "displayPrompt" as a possible overloaded argument. I still don't know how to delete multiple rows without getting an error!! Seems like the grid might be refreshing on each delete which is causing me some issues...
WAY to much overhead, just remove it from the datarow.
Really? I didn't think about that -- but my datarows don't have any distinct ID for me to know which row to delete at this time. So I really wouldn't know which row in my source I was deleting unless I gave them all ids..
When building a list (of any type, combo, grid etc) it is important to make sure that you pass a ID that can be referenced by the grid and data at the same time this is just a good habbit as if you have to access the data for any means (ie: update/insert,select from where) you have the corosponding record...
You need to go back and add a UID to each row and will make your life A LOT easier as the grid is just a repensitation of your database nothing more...
Got ya, well and I am going to eventually be saving this data offline, so yes I agree it needs to be done. I'll do it now so that I can delete my rows more efficiently. Thanks for the advise..
Another option would be to select the rows and call the DeleteSelected method on the grid.
Hi Jit,
You should post this in the appropriate WPF forum. Thi forum is for the Windows Forms grid, so I'm afraid I can't help you with XamDataGrid.
I'm getting the same error . But in my case I'm not deleting any rows . I'm removing column from front end from xam datagrid . And when again try to bind data to xam datagrid It's throws unhandled exception "Enumerator Has Exhasued"
at Infragistics.Collections.SparseArray.CreateItemEnumerator.EnsureNotExhausted() at Infragistics.Collections.SparseArray.CreateItemEnumerator.System.Collections.IEnumerator.MoveNext() at Infragistics.Windows.DataPresenter.RecordCollectionBase.RecordEnumeratorBase.MoveNext() at Infragistics.Windows.DataPresenter.AutoSizeFieldLayoutInfo.OutOfViewRecordEnumerable.Enumerator.MoveNext() at Infragistics.Windows.DataPresenter.AutoSizeFieldHelper.RecordEnumeratorBase.MoveNext()
Any thing I'm missing ?