This is a migrated thread and some comments may be shown as answers.

Row and Column Index of Edit Cell

3 Answers 265 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 2
Stefan asked on 23 Jul 2013, 04:32 PM
Hi,

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

Sort by
0
Stefan
Top achievements
Rank 2
answered on 23 Jul 2013, 07:49 PM
Anyone? I been battling this thing for hours.  I need a way to get the edit column index and row index.  I have tried everyway I can think of...

            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
0
Stefan
Top achievements
Rank 2
answered on 25 Jul 2013, 04:56 PM
Please.... anyone... I am under the gun?

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?



0
Accepted
Konstantin Dikov
Telerik team
answered on 26 Jul 2013, 12:05 PM
Hi Stefan,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Stefan
Top achievements
Rank 2
Answers by
Stefan
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or