Cell item template binding
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
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.
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
- 3 Replies
- 4 Participants
-
TT thomas tomanek
- May 7, 2013 09:05 AM UTC
- May 27, 2014 01:17 PM UTC