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

How to add two radio buttons (Yes and No) in sfDataGrid column

Hi,

I want to add two radio buttons (Yes and No) inside template column of the sfDataGrid. Could you please share the example for this?

I want this kind of layout inside sfDataGrid column:



5 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team February 27, 2019 06:09 AM

Hi Deepa, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your requirement of “Showing two radio buttons inside the DataGrid column” in Xamarin.Forms can be achieved using CellTemplate of GridTemplateColumn. You can set the desired DataTemplate in the GridTemplateColumn based on your requirement. 
 
We have prepared sample based on your requirement, please find the sample by the following link. 
 
Sample link: GridEditSample 
 
In the sample, we have added columns and in the last column we have handled two Switch in the layout. 
 
We hope this helps. Please let us know, if you need any further assistance. 
 
Regards,
Subburaj Pandian V  
 



DE Deepa March 1, 2019 04:48 AM

The solution you provided is using xamarin.forms.
I want the solution for native xamarin android.

Please provide me the sample in native xamarin android


SP Subburaj Pandian Veluchamy Syncfusion Team March 4, 2019 04:34 AM

Hi Deepa, 
 
Sorry for the inconvenience caused. 
 
We have prepared sample based on your requirement “Showing radio button inside the DataGrid column” in Xamarin.Android. Please find the sample by the following link.

Sample link: GridTemplateColumn_Droid 
 
In the sample, we have loaded Radio Button inside the DataGrid column by using UserCellType property of GridTextColumn. Using this you can pass the required view to the custom column of Grid. 
 
You can refer the same by the following UG documentation, 
 
 
We hope this helps. Please let us know, if you have any concern. 
 
Regards,
Subburaj Pandian V  



DE Deepa March 4, 2019 04:49 AM

I already tried this code. But this adds only one radio button to the column.
I want to add two radio buttons 'Yes', 'No' to the column.

Whenever i try to add second radio button, it gives me empty column.

I have waiting for 3 days to add this functionality. Please provide the sample as soon as possible. 


SP Subburaj Pandian Veluchamy Syncfusion Team March 5, 2019 04:05 AM

 
Hi Deepa, 
  
Thank you for the update. 
  
We have prepared the sample based on your requirement “Load two radio button in template column” and please refer the following code snippet for Custom Cell class changes. 
  
[C#] 
public class CustomCell : GridCell 
{ 
    LinearLayout layout; 
    RadioButton radioButton; 
    RadioButton radioButton1; 
  
    public CustomCell(Context context) : base(context) 
    { 
        layout = new LinearLayout(this.Context); 
        radioButton = new RadioButton(this.Context); 
        radioButton1 = new RadioButton(this.Context); 
  
        layout.AddView(radioButton); 
        layout.AddView(radioButton1); 
  
        this.AddView(layout); 
    } 
  
    protected override void UnLoad() 
    { 
        if (this.Parent != null) 
            (this.Parent as VirtualizingCellsControl).RemoveView(this); 
    } 
  
    protected override void OnLayout(bool change, int l, int t, int r, int b) 
    { 
        this.layout.Layout(0, 0, this.Width, this.Height); 
    } 
  
    protected override void OnMeasure(int widthMeasureSpec, intheightMeasureSpec) 
    { 
        base.OnMeasure(widthMeasureSpec, heightMeasureSpec); 
        this.layout.Measure(widthMeasureSpec, heightMeasureSpec); 
    } 
  
    protected override void OnDraw(Canvas canvas) 
    { 
        base.OnDraw(canvas); 
        this.radioButton.Text = "Yes"; 
        this.radioButton1.Text = "No"; 
    } 
} 
  
We have attached the sample in following location. 
  
 
Please let us know, if this helpful. 
 
Regards,
Subburaj Pandian V 
 


Loader.
Live Chat Icon For mobile
Up arrow icon