We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

What is the best way to access RowData in OnCurrentCellBeginEdit event with group columns

I have a data grid with Group columns. I am using OnCurrentCellBeginEdit event to restrict write access to some cells based underneath row data values. Here is the code I am using inside OnCurrentCellBeginEdit  event:

if (args.Column.MappingName.Equals("Name"))
   var rowIndex = MyGrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);
   var rowData = (MyGrid.View.Records[rowIndex]).Data as Student

   if (rowData.Discontinued)
      args.Cancel = true;

Problem is rowData returned is not the row inwhich I clicked on Name cell, I am guessing its because of the grouping row. What is the best way to correctly access RowData in OnCurrentCellBeginEdit   event. Please let me know.

Note: Both args.RowColumnIndex.RowIndex & MyGrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex) doesnt work well.

3 Replies

JG Jai Ganesh S Syncfusion Team July 16, 2015 12:27 PM UTC

Hi Vasanth,

Thank you for using Syncfusion products.

We have analyzed your query. You can achieve your requirement like getting the row data from DisplayElements in grouping case by using the corresponding resolved record index.

Code Snippet [C#]:

void datagrid_CurrentCellBeginEdit(object sender, CurrentCellBeginEditEventArgs args)


            if (args.Column.MappingName.Equals("EmployeeName"))


                   var recordIndex = datagrid.ResolveToRecordIndex(args.RowColumnIndex.RowIndex);

                   if (this.datagrid.View.TopLevelGroup != null)


                       // Get the current row record while grouping

                       var record = this.datagrid.View.TopLevelGroup.DisplayElements[recordIndex];

                       // data of record as type cast to OrderInfo

                       var rowData = (record as RecordEntry).Data as BusinessObjects;

                       if (rowData.EmployeeName == "Mart")

                           args.Cancel = true;




                       // Get the current row record

                       var record1 = this.datagrid.View.Records.GetItemAt(recordIndex);

                       if ((record1 as BusinessObjects).EmployeeName == "Mart")

                           args.Cancel = true;




We have also prepared the sample based on this and please find the sample under the following location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/141139/ze/SfDataGridDemo227932121

KB Link:


Please let us know if you need further assistance.

Thank you,

Jai Ganesh S

VA Vasanth July 16, 2015 01:55 PM UTC

perfect, works like a champ. thank you!

AR Antony Raj M Syncfusion Team July 18, 2015 02:52 PM UTC

Hi Vasanth,

Thanks for your update. Please let us know if you need further assistance on this.

Antony Raj

Live Chat Icon For mobile
Up arrow icon