I am looping through the BatchEditCommand in vb and need to get the row index and column index of each row that was edited? Is it possible?
For Each item As GridBatchEditingCommand In e.Commands
Dim editedRow = item
iRowIndex = ?
iColIndex = ?
End Select
Next
Thanks
3 Answers, 1 is accepted

For Each item As GridBatchEditingCommand In e.Commands
Dim editedRow = item
Dim editedCol = dgCompGrid.MasterTableView.Items(dgCompGrid.SelectedItems(0).ItemIndex)
Dim iRow As Int32
Dim iCol As Int32
iRow = item.Item.ItemIndex
iCol = dgCompGrid.SelectedItems(0).ItemIndex
iCol = dgCompGrid.Columns.IndexOf(dgCompGrid.Columns(item.Item.RowIndex).UniqueName)
'iCol = item.Item
'iColName = dgCompGrid.Columns(item.Item.RowIndex).UniqueName
iCol = item.OwnerTableView.GetColumn(dgCompGrid.Columns(item.Item.ItemIndex).UniqueName).EditFormColumnIndex
Label1.Text = "Name: " & dgCompGrid.Columns(item.Item.RowIndex).UniqueName & " Row = " & iRow & "----" & "Col = " & iCol
Next
Looping through each GridBatchEditingCommand I need the Row Index and the Column Index and/or Column Name of the edited row? Is this even possible?
thanks

I just need the column index of the edited row of a GridbatchEditingCommand? Surely the grid stores the column of a batch edit row somewhere? If not just please say so then I can ditch the telerik and try something else. Is it faster to just email support with my questions?
Thank you for contacting us.
There is no out of the box functionality that will allow you to get the edited cells column indexes. Only row index of the Item can be easily retrieved.
The only approach I can suggest to get the edited cells column indexes is by following those steps:
- Traverse through the OldValues and NewValues of every Item;
- If some of the values are not equal you get the key associated with that value (which represents the column name);
- Use the RadGrid1.Columns.FindByUniqueName method to retrieve that GridColumn in question;
- Find the column index with RadGrid1.Columns.IndexOf(GridColumn).
Bellow is an example on how to implement the above where editItemRowIndex is the edited cell row index, and the indexOfEditedColumn is the column index:
Protected
Sub
RadGrid1_BatchEditCommand(sender
As
Object
, e
As
GridBatchEditingEventArgs)
For
Each
command
As
var
In
e.Commands
If
command.Type = GridBatchEditingCommandType.Update
Then
Dim
editItemRowIndex
As
Integer
=
Integer
.Parse(command.Item.ItemIndexHierarchical)
For
Each
columnName
As
String
In
command.NewValues.Keys
If
command.NewValues(columnName) <> command.OldValues(columnName)
Then
Dim
editedColumn
As
GridColumn = RadGrid1.Columns.FindByUniqueName(columnName)
Dim
indexOfEditedColumn
As
Integer
= RadGrid1.Columns.IndexOf(editedColumn)
End
If
Next
End
If
Next
End
Sub
Hope this helps.
Best Regards,
Konstantin Dikov
Telerik