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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

130623 May 22,2017 02:45 PM May 23,2017 01:16 AM WPF 1
loading
Tags: SfDataGrid
Eric Clum
Asked On May 22, 2017 02:45 PM

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">
                            <syncfusion:GridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button x:Name="ButtonDelete" Click="ButtonDelete_Click" Content="Delete" />
                                </DataTemplate>
                            </syncfusion:GridTemplateColumn.CellTemplate>
                        </syncfusion:GridTemplateColumn>

Srinivasan Vasu [Syncfusion]
Replied On May 23, 2017 01:16 AM

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.Remove("TemplateExt");   
this.datagrid.CellRenderers.Add("TemplateExt"new GridCellTemplateExt());   
   
public class GridCellTemplateExt : GridCellTemplateRenderer   
{   
    protected override void SetFocus(FrameworkElement uiElement, bool needToFocus)   
    {   
        if (!needToFocus)   
            DataGrid.Focus();   
    }   
}   
   
In the below sample, we have created the custom column and custom renderer from GridTemplateColumn and focus the element to grid cell.   
   
  
Regards, 
Srinivasan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;