Prevent RowSelected-Event when clicking checkbox.

I need a checkbox in every row of my grid in order to set a flag (not for selecting).
In addition I need to be able to select multiple rows by clicking on them (but not by clicking the checkbox).

My problem is that clicking on checkboxes also triggers the selection , and instead of check/uncheck the checkbox , it will select/deselect the row.

6 Replies

SS Sampathnarayanan Sankaralingam Syncfusion Team March 10, 2022 02:08 PM UTC

Hi Vicky, 
 
We suspect that you can achieve your requirement by using the GridCheckBoxColumn instead of using GridCheckBoxSelectorColumn. Please refer the below UG for more details. 
 
 
Please let us know if you have any concerns. 
 
Regards, 
Sampath Narayanan.S 



VD Vicky Diana March 14, 2022 02:56 PM UTC

No  , I am using the GridCheckBoxColumn and it still selects/deselects the row..



SS Sampathnarayanan Sankaralingam Syncfusion Team March 16, 2022 07:19 PM UTC

Hi Vicky,


We have checked the requirement. You can restrict the selection when clicking the checkbox using the following code snippet.


this.sfdatagrid.CurrentCellActivating += Sfdatagrid_CurrentCellActivating;

 

private void Sfdatagrid_CurrentCellActivating(object sender, CurrentCellActivatingEventArgs e)

{

    var columnIndex = this.sfdatagrid.ResolveToGridVisibleColumnIndex(e.CurrentRowColumnIndex.ColumnIndex);

    var columnName = this.sfdatagrid.Columns[columnIndex].MappingName;

 

    if(columnName == "IsChecked")

    {

        e.Cancel = true;

    }

}


https://www.syncfusion.com/downloads/support/forum/173505/ze/CS935053927


Please refer the sample from the above link and let us know if you have any concerns.


Regards,

Sampath Narayanan.S



VD Vicky Diana March 17, 2022 04:53 PM UTC

That would help , but still have some problems..

Instead of that , is there a way , so that when clicking the same checkbox repeatedly, instead of having the row always deselected , it stays selected ?  So , I click the checkbox on a new row , it marks the change in the checkbox , selects the row , and if I click again on the same checkbox , the row stays selected .

I need this because a have a command for the CurrentCellValueChanged , and in this case, if the checkbox value was changed , this method should trigger the RowValidatedEvent by SetCurrentRowValidated on false

With your solution , the  RowValidatedEvent it's not triggered , because ( I think so ) there is no CurrentRow




SS Sampathnarayanan Sankaralingam Syncfusion Team March 18, 2022 04:02 PM UTC

Hi Vicky, 

We are checking the possibilities to achieve the requirement. We will check and update you more details on March 22, 2022. 

Regards, 
Sampath Narayanan.S 



SS Sampathnarayanan Sankaralingam Syncfusion Team March 22, 2022 03:46 PM UTC

Hi Vicky,  
 
We have checked the requirement of yours. If we disable the selection process, current cell events will not raise. However you can use the template column instead of Checkbox column to achieve your requirement. CurrentCellValueChanged event will not trigger if you are using TemplateColumn however you can raise rowvalidate event in the CheckBoxClick event. Please refer the sample from below link and let us know if you have concerns. 
 
 
Regards, 
Sampath Narayanan.S 


Loader.
Up arrow icon