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

Event for checkbox

I have an sfdatagrid with auto generated columns. One of these is a boolean/checkbox. I want to respond to a checkbox being checked so that I can refresh the grid (so it re-sorts itself). How can I do this?

9 Replies

AN Ashok N Syncfusion Team September 11, 2017 10:20 AM UTC

Hi Tino,   
  
We cannot able to listen the Tap action on the Switch while change the value, already we will consider this as feature enhancement of GridSwitchColumn and this GridSwitchColumn events support will be available in our upcoming 2017 Vol 3 SP2 release, which will be schedule for rolls out end of September. We appreciate your patience until then.  
 
Regards,   
Ashok  



DU DukeMeister September 11, 2017 02:41 PM UTC

Thanks. I'm also curious why the GridSwitchColumn shows as a checkbox and not as a switch (in Android).



AN Ashok N Syncfusion Team September 12, 2017 06:09 PM UTC

Hi Tino, 
 
Thanks for your update.  
 
In Xamarin.Forms.Android we have loaded the Switch as CheckBox because of the customer requirement. Many of the customers requested CheckBox only instead of loading switch. We can able to customize this by overriding GridColumn column and that as GridColumn CellType. 
 
Regards, 
Ashok  



DW Dirk Wessels replied to Ashok N October 11, 2017 05:15 AM UTC

Hi Tino,   
  
We cannot able to listen the Tap action on the Switch while change the value, already we will consider this as feature enhancement of GridSwitchColumn and this GridSwitchColumn events support will be available in our upcoming 2017 Vol 3 SP2 release, which will be schedule for rolls out end of September. We appreciate your patience until then.  
 
Regards,   
Ashok  


Hi,

Can you tell me when this will be available please. You mention end of September, but as far as I can see the latest release was on 7 August.

https://www.syncfusion.com/downloads/latest-version

I really need this functionality.



AN Ashok N Syncfusion Team October 12, 2017 04:58 AM UTC

Hi Dirk,    
 
We are sorry about the inconvenience caused. 
    
We have checked the editing event support for GridSwitchColumn in our SfDataGrid Control and normally SwitchColumn didn’t have editing events support, this is DataGrid behavior so we cannot able to provide the edit event support (like CurrentCellBeginEdit and CurrentCellEndEdit) for GridSwitchColumn. Instead of this we will provide the ValueChanged event support. Within this event args we will provide the Original Sender, Column, RowColumnIndex and Record. If you require any other event args , please share the details, We will progress this work once you provide the requirement details. Hence, we did not include this support in our 2017 Vol 3 SP2 release.  
 
Regards,    
Ashok   



HS Hermann Swart April 27, 2018 06:11 AM UTC

Hi,
is there an update on when this will be realized?

We also need this event.


SK Suriya Kalidoss Syncfusion Team April 30, 2018 11:02 AM UTC

Hi Hermann, 
Thank You for using Syncfusion Products, 
  We had analyzed your requirement. To get Switch toggle event use the custom renderer class. Refer the below code snippet for how to write custom renderer class for switch column. 
Code logics: 
  sfGrid.CellRenderers.Remove("Switch"); 
  sfGrid.CellRenderers.Add("Switch", new Gridswitchcontrol()); 
 
//Custom Renderer Class 
 
  public class Gridswitchcontrol:GridCellSwitchRenderer 
        { 
          public  Gridswitchcontrol() 
            { 
 
            } 
          
            public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfSwitchControl view) 
            { 
                base.OnInitializeDisplayView(dataColumn, view); 
   
                view.Toggled += View_Toggled; 
            } 
 
            private void View_Toggled(object sender, ToggledEventArgs e) 
            { 
               //Your Requirement here 
            } 
        } 
 
We had attached sample for your reference, you can download it from the below link. 
Regards, 
Suriya K 



HN Huy Nguyen Xuan March 28, 2019 08:05 AM UTC

I also encountered the same problem as this friend asked.
So is there any other way to detect GridSwitchColumn changes ?.
 

==> My purpose is to sum the rows being checked
Thank you


SP Subburaj Pandian Veluchamy Syncfusion Team March 29, 2019 09:05 AM UTC

Hi Huy Nguyen Xuan, 
  
Your requirement of “Detecting GridSwitch column value changes” can be achieved by using ValueChanged event of DataGrid. Please refer the following code to achieve your requirement. In that we have hooked ValuChanged event in GridLoaded event to avoid calculation in initial loading. 
  
[C#] 
dataGrid.GridLoaded += DataGrid_GridLoaded; 
  
private void DataGrid_GridLoaded(object sender, GridLoadedEventArgs e) 
{ 
    // if we call ValueChanged event in Grid Loaded value changed will not 
    // raised in initial loading. 
    dataGrid.ValueChanged += DataGrid_ValueChanged; 
     
    //Sum of rows being checked. 
    var count = viewModel.OrdersInfo.Count(x => x.IsClosed); 
} 
  
private void DataGrid_ValueChanged(object sender, Syncfusion.SfDataGrid.XForms.ValueChangedEventArgs e) 
{ 
    if(e.Column.MappingName == "IsClosed") 
    { 
        // Calculating sum of rows checked when the grid switch column value is changed. 
        var count = viewModel.OrdersInfo.Count(x => x.IsClosed); 
    } 
} 
  
We have prepared sample for your reference, 
 
  
Please let us know, if this helpful. 
 
Regards,
Subburaj Pandian V 


Loader.
Up arrow icon