CurrentCellActivatedCommand Event - Incorrect Column ID with DetailsView column

Hi,
I am using the CurrentCellActivatedCommand event on the control to detect if a user clicks any of columns 2 to 3 within a 6 column layout.
Within my grid, I have a DetailsViewDefinition and when the application runs, I get the default Expand/Collapse column appear correctly.

The issue is that when I use the above Event and a user clicks the Expand/Collapse button of a row, I get the correct Row returned within the CurrentCellActivatedEventArgs however the column reference is incorrect. It appears to be the last non-expand collapse column that was selected in any other row. e.g. If I click column 5 on Row 2 and then click column 1 (Expand/Collapse column) on Row 10, the CurrentCellActivatedEventArgs shows 10 as the row index (correct) but 5 for the column index (wrong)

Is there some property I need to change to get this to work or would a different Event be better for this? I essentially want some action to occur only if a user clicks in columns 2 or 3 of the grid and not if a user is just clicking the Expand/Collapse button

Many thanks,

1 Reply

JG Jai Ganesh S Syncfusion Team August 16, 2016 02:17 PM UTC

Hi Ross, 
 
While we click column 5 on Row 2 and then click column 1 (Expand/Collapse column) on Row 10, the current cell moves to column 5 on Row 10 and CurrentCellActivatedEventArgs shows 10 as the row index and 5 for the column index. This is the default behavior of SfDataGrid.  
 
Screen Shot: 
 
 
 
However, you can do the action if you only clicking a column 2 or 3 by wiring the PreviewMouseUp event like below, 
 
void dataGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) 
{ 
    var rowcolindex = this.dataGrid.GetVisualContainer().PointToCellRowColumnIndex(e.GetPosition(this.dataGrid.GetVisualContainer())); 
    if(rowcolindex.ColumnIndex == 2 || rowcolindex.ColumnIndex == 3) 
    { 
        //Do your actions here 
    } 
} 
 
 
Regards, 
Jai Ganesh S 


Loader.
Up arrow icon