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
close icon

Clicking a Button in SfDataGrid does not fire Click event until 2nd click

I have a Button in a GridTemplateColumn of a SFDataGrid.  When you click it, it seems like it selects the cell first. Then you have to click it again to get the click event to fire.  (The built in DataGrid in Visual Studio does not do this)  Is this the designed behavior and is there a way around this? 
                        <syncfusion:GridTemplateColumn Width="55">
                                    <Button x:Name="ButtonDelete" Click="ButtonDelete_Click" Content="Delete" />

1 Reply

SV Srinivasan Vasu Syncfusion Team May 23, 2017 05:16 AM UTC

Hi Eric,   
Thank you for contact Syncfusion support.   
We have analyzed your query.  You can achieve your requirement by override SetFocus() method in GridCellTemplateRenderer class as like below code sample  
Code Snippet:   
this.datagrid.CellRenderers.Add("TemplateExt"new GridCellTemplateExt());   
public class GridCellTemplateExt : GridCellTemplateRenderer   
    protected override void SetFocus(FrameworkElement uiElement, bool needToFocus)   
        if (!needToFocus)   
In the below sample, we have created the custom column and custom renderer from GridTemplateColumn and focus the element to grid cell.   

Live Chat Icon For mobile
Up arrow icon