I want to add a Button to each line in the grid (this is what I have now)
<igGrid:XamWebGrid.Columns> <igGrid:TextColumn Key="TDescription" HeaderText="Description" IsReadOnly="True" HorizontalContentAlignment="Left"/> <igGrid:TextColumn Key="TReportDescription" HeaderText="Report Description" IsReadOnly="True" HorizontalContentAlignment="Left"/> <igGrid:TemplateColumn Key="LEnabled" HeaderText="Enabled" IsReadOnly="True" HorizontalContentAlignment="Center"> <igGrid:TemplateColumn.ItemTemplate> <DataTemplate> <CheckBox IsChecked="{Binding LEnabled}"></CheckBox> </DataTemplate> </igGrid:TemplateColumn.ItemTemplate> </igGrid:TemplateColumn> <igGrid:TemplateColumn Key="Edit" HeaderText=" "> <igGrid:TemplateColumn.ItemTemplate> <DataTemplate> <Button Tag="{Binding}" Content="Edit" Width="Auto" Height="Auto" Click="Button_Click"></Button> </DataTemplate> </igGrid:TemplateColumn.ItemTemplate> </igGrid:TemplateColumn> </igGrid:XamWebGrid.Columns> </igGrid:XamWebGrid>
I want to store the Rows data object in the Tag of the button so I can get the data in the click event. Is this possible as I keep getting the Error
The following key(s) do not correspond with the DataSource: "Edit". If you'd like to add additional columns, please use the TemplateColumn type.
The Edit key is not in the datasource its just a name I have to the TemplateColumn.
Help..
Thanks David.
Hi David,
So this is a breaking change we are introducing in 10.1. We've added an Unbound column which should be used for custom templates such as this. And now a TemplateColumn is considered a "bound" column. Meaning it must be associated with a property in your data model. By doing this, we hope to eliminate confusion that some or our customers were running into, when want to have a bound column, but want to customize how the content looks. Bound columns have the luxury of being able to be sorted, filtered, grouped by, etc. While the unbound column should be used in situations where you have a calculated value not in your data model, or such things as a Button in a column.
Hope this helps clear things up.
-SteveZ
Thanks for the reply. I will change it to a UnboundColumnTemplate. However if it is an UnboundColumn can I still use the {Binding} to get the Row Data as the column is not bound to the data.
<Button Tag="{Binding}" Content="Edit" Width="Auto" Height="Auto" Click="Button_Click"></Button>
David
Sorry, i forgot to mention, the DataContext is slightly different to offer more options:
The DataContext is of type UnboundColumnDataContext. which has the following values : RowData, Value, and ColumnKey.
So, for your scenario, you would use {Binding RowData}
Hope this helps,