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

Usage of Record.Data within DataTemplates

Hi Guys,

This page (http://help.syncfusion.com/ug/wpf/grid/default.htm#!documents/datatemplate.htm) states it should be possible to access underlying object bindings within a Data Template via {Binding Record.Data.xzy}.  

This doesn't appear to work - do you have an example/sample that demonstrates this for the GridTreeControl?

Thanks,

Adam

1 Reply

AN Ashok N Syncfusion Team June 6, 2014 12:30 PM UTC

Hi Adam,


Thank you for contacting Syncfusion Support.

We analyzed your query. In GrirTreeControl don’t have support to access underlying object bindings within a Data Template via {Binding Record.Data.xzy}. In our UGDocumentation we put this information as wrongly. We will change this information in our UGDocumentation ASAP. But you can bind some other object value to DataTemplate column means use QueryCellInfo event and store the items to e.Style.CellValue2. Using this CellValue2 you can bind the other object value within DataTemplate. Please refer the below code snippet

XAML code:

<syncfusion:GridTreeColumn HeaderText="First Name" MappingName="FirstName" >

                <syncfusion:GridTreeColumn.StyleInfo>

                    <syncfusion:GridStyleInfo CellType="DataBoundTemplate">

                        <syncfusion:GridStyleInfo.CellItemTemplate>

                            <DataTemplate>

                                <TextBlock Text="{Binding Style.CellValue2.LastName}"/>

                            </DataTemplate>

                        </syncfusion:GridStyleInfo.CellItemTemplate>

                    </syncfusion:GridStyleInfo>

                </syncfusion:GridTreeColumn.StyleInfo>

            </syncfusion:GridTreeColumn>

 

C# Code snippet:

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

{

    if (e.Style.CellType == "DataBoundTemplate")

    {

        var node = treeGrid.InternalGrid.GetNodeAtRowIndex(e.Style.RowIndex);

        if (node != null)

        {

            var item = node.Item as EmployeeInfo;

            e.Style.CellValue2 = item;

        }

    }

}

 

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/125862/CS-513814108.zip


Please let us know if you require further assistance

Thanks,

Ashok


Loader.
Live Chat Icon For mobile
Up arrow icon