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

Cell item template binding

Hi,

Is there a way to specify a binding in a cell item template that references what would logically be the datacontext of the row (although looking at the visual tree I don't see an actual row object). What I want is a cell template that combines the values from a few different objects on the data context but at the moment I'm stuck binding only to the CellBoundValue.

I'm looking at migrating from Xceed's grid, but in that grid I can easily specify a relative source binding from the cell template to grab the datacontext of the row.

Hope that makes sense,
Cheers

3 Replies

DA Divya A Syncfusion Team May 14, 2013 06:38 AM UTC

Hi Thomas,

 

You can bind the entire Record of the particular row to the DataTemplate objects by binding Record.Data. You can also access the corresponding Column value by its MappingName as in the following code snippet.

 

 

Code Snippet:

 

  <syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">
      <syncfusion:GridDataVisibleColumn.CellItemTemplate>
           <DataTemplate>
              <StackPanel Orientation="Horizontal">
                 <TextBlock Text="{Binding Record.Data.CustomerID}" Width="75"/>
                 <TextBlock Text="{Binding Record.Data.CustomerName}" Width="75"/>
              </StackPanel>
           </DataTemplate>
      </syncfusion:GridDataVisibleColumn.CellItemTemplate>
  </syncfusion:GridDataVisibleColumn>

 

 

Please let us know if you have any concerns.

 

Regards,

Divya.



MC Michael Cheng April 10, 2014 09:02 PM UTC

What does this mean?
"You can also access the corresponding Column value by its MappingName as in the following code snippet."

In the data template?


GV Ganesan V Syncfusion Team May 27, 2014 01:17 PM UTC

Hi Thomas,

 

Thank you for your patience.

 

If you want to display the CellBoundValue to the template column, you can display it by using the CellBoundValue , Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">

      <syncfusion:GridDataVisibleColumn.CellItemTemplate>

           <DataTemplate>

              <StackPanel Orientation="Horizontal">

                 <TextBlock Text="{Binding Path=CellBoundValue}" Width="75"/>

              </StackPanel>

           </DataTemplate>

      </syncfusion:GridDataVisibleColumn.CellItemTemplate>

  </syncfusion:GridDataVisibleColumn>

 

And also If you want to display the corresponding column value to the template column, you can use the Record.Data.MappingName. Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">

      <syncfusion:GridDataVisibleColumn.CellItemTemplate>

           <DataTemplate>

              <StackPanel Orientation="Horizontal">

                 <TextBlock Text="{Binding Record.Data.ProductID}" Width="75"/>

              </StackPanel>

           </DataTemplate>

      </syncfusion:GridDataVisibleColumn.CellItemTemplate>

  </syncfusion:GridDataVisibleColumn>

 

If you want to display the other property value in column, you can bind as Record.Data.PropertyName. Please refer the following code snippet,

 

<syncfusion:GridDataVisibleColumn HeaderText="ProductID" MappingName="ProductID">
      <syncfusion:GridDataVisibleColumn.CellItemTemplate>
           <DataTemplate>
              <StackPanel Orientation="Horizontal">
                 <TextBlock Text="{Binding Record.Data.CustomerID}" Width="75"/>
                 <TextBlock Text="{Binding Record.Data.CustomerName}" Width="75"/>
              </StackPanel>
           </DataTemplate>
      </syncfusion:GridDataVisibleColumn.CellItemTemplate>
  </syncfusion:GridDataVisibleColumn>

 

Please let us know if you have any queries,

 

Regards,

Ganesan V

 


Loader.
Live Chat Icon For mobile
Up arrow icon