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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to click a button directly without focus on a CellTemptate of a sfDataGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

123676 Apr 10,2016 06:44 AM UTC Jun 20,2018 07:09 AM UTC WPF 6
loading
Tags: SfDataGrid
MARQUANT Cédric
Asked On April 10, 2016 06:44 AM UTC

Hi,
My use case is : I have a sfDatagrid, with a GridTemplateColumn containing a single button.
To launch the method behind the button I have to :
- click one time to focus the row
- click again to launch the method behind the button
Is there a way to achieve it (Focus + button click) in one single click ?
It is important to set the focus because the button role is to open a "More Details" for the row.
Regards,

Jayapradha S [Syncfusion]
Replied On April 11, 2016 04:43 AM UTC

Hi Marquant,

Thank you for contacting Syncfusion Support.

We have analyzed your query. You can set the focus to button without focus on a celltemplate by setting Syncfusion.FocusManagerHelper.FocusedElement to true as shown below,

Code Example:

 <Syncfusion:GridTemplateColumn>

                    <Syncfusion:GridTemplateColumn.CellTemplate>

                        <DataTemplate>

                            <Button Width="Auto" Syncfusion:FocusManagerHelper.FocusedElement="True" 

                                    Height="Auto"

                                    Click="Button_Click"

                                    Content="Call” />

                        </DataTemplate>

                    </Syncfusion:GridTemplateColumn.CellTemplate>

  </Syncfusion:GridTemplateColumn>


Please refer the below KB Link,
KB Link: https://www.syncfusion.com/kb/3206/how-to-edit-sfdatagrid-template-column-by-single-tap

Regards,
Jayapradha


Jayapradha S [Syncfusion]
Replied On April 11, 2016 04:43 AM UTC

Hi Marquant,

Thank you for contacting Syncfusion Support.

We have analyzed your query. You can set the focus to button without focus on a celltemplate by setting Syncfusion.FocusManagerHelper.FocusedElement to true as shown below,

Code Example:

 <Syncfusion:GridTemplateColumn>

                    <Syncfusion:GridTemplateColumn.CellTemplate>

                        <DataTemplate>

                            <Button Width="Auto" Syncfusion:FocusManagerHelper.FocusedElement="True" 

                                    Height="Auto"

                                    Click="Button_Click"

                                    Content="Call” />

                        </DataTemplate>

                    </Syncfusion:GridTemplateColumn.CellTemplate>

  </Syncfusion:GridTemplateColumn>


Please refer the below KB Link,
KB Link: https://www.syncfusion.com/kb/3206/how-to-edit-sfdatagrid-template-column-by-single-tap

Regards,
Jayapradha


MARQUANT Cédric
Replied On April 11, 2016 04:48 AM UTC

Thanks ! 

It works perfectly.

Regards,

Jayapradha S [Syncfusion]
Replied On April 12, 2016 05:03 AM UTC

Hi Marquant

Thank you for your update.

Please let us know if you require any other assistance.

Regards,
Jayapradha

Helmut Jilka
Replied On June 19, 2018 11:45 AM UTC

I have a similar problem, but I have 2 buttons inside a DataGrid Cell ("moving line up/down" buttons)
Using syncfusion:FocusManagerHelper.FocusedElement="True" works fine for one of the buttons but clicking the second button works only at the second click.

Is there a solution for this as well?





Sathiyathanam Jeyakumar [Syncfusion]
Replied On June 20, 2018 07:09 AM UTC

Hi Marquant, 
 
We have analyzed your query and you can achieve your requirement by set the focus for the both buttons inside the DataGridCell. Please find the below code snippets to set the focus for the buttons. 
 
Code snippets : 
 
<syncfusion:GridTemplateColumn > 
                    <syncfusion:GridTemplateColumn.CellTemplate> 
                        <DataTemplate> 
                            <Grid> 
                                <Grid.ColumnDefinitions> 
                                    <ColumnDefinition/> 
                                    <ColumnDefinition/> 
                                </Grid.ColumnDefinitions> 
                                <Button x:Name="button1" Grid.Column="0" Click="button1_Click" Height="20" syncfusion:FocusManagerHelper.FocusedElement="True" Content="B1"/> 
                                <Button x:Name="button2" Grid.Column="1" Click="button2_Click" Height="20" syncfusion:FocusManagerHelper.FocusedElement="True" Content="B2"/> 
                            </Grid> 
                        </DataTemplate> 
                    </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 
 
You can download the testing sample from the below location. 
 
 
If the issue is still persisting, could you please provide the sample to us based on your application, this will help us to analyze further and provide the better solution to you. 
 
 
Regards, 
Sathiyathanam 


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.

Warning Icon 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.Close Icon

;