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

is there any code sample for this GridCellRendererCollection ?

Hi, can you please elaborate this GridCellRendererCollection class, how can we use this exact and where can we use ?


1 Reply

DS Divakar Subramaniam Syncfusion Team February 14, 2017 06:48 AM UTC

Hi Kumaraswamy, 
In SfDataGrid, we have maintained separate renderers for separate views in dictionaries (with key and value pair). For example, in GridSwitchColumn, we have loaded SfSwitchControl which is derived from Xamarin.Forms.Switch and we customized the switch view in renderer projects separately where we have loaded native switch controls for Android, iOS and UWP. 
Also, you can customize those renderers by writing your own custom renderer. For that, you have to remove the existing renderer from the GridCellRenderer collection and add your custom renderer. Please refer the below code snippet. 
// In code-behind 
dataGrid.CellRenderers.Add("Switch",new CustomSwitchRenderer()); 
public class CustomSwitchRenderer : GridCellSwitchRenderer 
    public override void OnInitializeDisplayView(DataColumnBase dataColumn, SfSwitchControl view) 
        base.OnInitializeDisplayView(dataColumn, view); 
        view.IsEnabled = false; 
In the above code, we have written a new renderer which is derived from GridCellSwitchRenderer. And then removed the existing switch renderer from the CellRenderers collection and added our own renderer. 
We have prepared a simple sample for your reference and you can download the same from the below link. 
Please refer the below KB link. In the KB we have written a new renderer HeaderCell in Xamarin.iOS platform(modify the code based on Xamarin.Forms platform). We have attached this KB for your reference and which will help you to understand better. 

Live Chat Icon For mobile
Up arrow icon