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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

AncestorType for a button inside a column of a Master-Details datagrid

Thread ID:

Created:

Updated:

Platform:

Replies:

120887 Oct 25,2015 01:55 PM UTC Oct 27,2015 04:20 AM UTC WPF 3
loading
Tags: SfDataGrid
MARQUANT Cédric
Asked On October 25, 2015 01:55 PM UTC

Hi,

I have a button that launch a specifi command inside a column of my datagrid, in the details part of a master-details.

The button command is define as also :

Command="{Binding DataContext.SupprimerVilleCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type syncfusion:SfDataGrid}}}"

But the command is never launched, and an error is displayed in Visual Studio output window :

System.Windows.Data Error: 40 : BindingExpression path error: 'SupprimerDepartementCommand' property not found on 'object' ''EntityCollection`1' (HashCode=39200294)'. BindingExpression:Path=DataContext.SupprimerDepartementCommand; DataItem='DetailsViewDataGrid' (Name=''); target element is 'Button' (Name=''); target property is 'Command' (type 'ICommand')

What is the correct AncestorType to specify in this case ?

Thanks for your help.

Regards,

Jai Ganesh S [Syncfusion]
Replied On October 26, 2015 12:19 PM UTC

Hi MARQUANT,

Thank you for using Syncfusion Products.

You can achieve your requirement to launch the button command inside the details view datagrid column by setting the AncestorLevel based on the details grid level like the below code example,
Code Example:

<syncfusion:GridTemplateColumn MappingName="CustomerID" syncfusion:FocusManagerHelper.WantsKeyInput="True">

        <syncfusion:GridTemplateColumn.CellTemplate>

                <DataTemplate>

             <Button  Content="Click" syncfusion:FocusManagerHelper.FocusedElement="True"

        Command="{Binding Path=DataContext.ToggleExecuteCommand,RelativeSource={RelativeSource AncestorLevel=2, AncestorType=syncfusion:SfDataGrid}}" />

                </DataTemplate>

       </syncfusion:GridTemplateColumn.CellTemplate>
 </syncfusion:GridTemplateColumn>



We have prepared a sample based on this and you can download the sample from the below location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/145693/ze/MasterDetailsViewDemo-255495418

Please let us know if you need further assistance.

Regards,
Jai Ganesh S

MARQUANT Cédric
Replied On October 26, 2015 05:54 PM UTC

Thanks it works perfectly...

Jai Ganesh S [Syncfusion]
Replied On October 27, 2015 04:20 AM UTC

Hi MARQUANT,

Thank you for the update.

Please let us know if you need further assistance on this.

Regards,
Jai Ganesh S

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

;