I am using RadGridView in Silverlight application and binding it to a DataTable . For my RadGridView I have set AutoGenerateColumns = "True" (to get my columns automatically).
Now I want add two GridViewColumns Template having some Imgae control inside it.
So how can I implement this Scenario with setting AutoGenerateColumns = "True"
Thanks-
11 Answers, 1 is accepted
There are two options for you :
1. You can manually define the two special columns. RadGridView will display them along with the autogenerated columns.
2. You can handle the AutogeneratingColumn event , and assign your templates inside the event handler for the columns RadGridView has generated for you.
Regards,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
How can I manually define the two special columns. Can you provide some sample code for same
Thanks-
Some XAML for manually defining an image column may be found here.
All the best,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I have set AutoGenerateColumns = "True" in that case it removed static columns and only display column from DataTable
So how can I add my static column with Auto Generated column.
Thanks-
That is confusing. By design RadGridView will show manually defined columns along with the autogenerated.
We have never observed the behavior described.
I sounds like you have hit a bug . Can you please share your XAML/cs with me so I can test it here.
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
<telerik:RadGridView x:Name="tableDataGrid" Grid.Row="0" IsReadOnly="True" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False"
CanUserFreezeColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" CanUserSelect="True" RowIndicatorVisibility="Collapsed"
ShowGroupPanel="False" HorizontalAlignment="Stretch" DataContext="{Binding TableData}" SelectionChanged="tableGrid_SelectionChanged"
AutoGeneratingColumn="tableDataGrid_AutoGeneratingColumn">
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header="Text" Background="WhiteSmoke" IsSortable="False" IsFilterable="False" Width="45" IsReadOnly="True">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<HyperlinkButton BorderThickness="0" Foreground="#FF034CFF" Margin="4,0,2,0" x:Name="addRowButton" HorizontalAlignment="Right" Click="addRowtButton_Click"
Background="Transparent" VerticalAlignment="Top" ToolTipService.ToolTip="Insert new row">
<Image Source="/Toolbox;component/Images/AddRow.png" Height="20"></Image>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
It removed my static column that is Hyperlinklink button image.
I gathered your XAML in a project . It displays both the autogenerated and the manually set column .
You can find it attached.
All the best,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I have two static columns like [ one is for "Add New Row" and other is "Delete Row"] and In between I want add Auto Genrated columns
How Can I implement this scenario?
<telerik:RadGridView x:Name="tableDataGrid" Grid.Row="0" IsReadOnly="True" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False"
CanUserFreezeColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" CanUserSelect="True" RowIndicatorVisibility="Collapsed"
ShowGroupPanel="False" HorizontalAlignment="Stretch" ItemsSource="{Binding TableData}"
>
<telerik:RadGridView.Columns>
<telerik:GridViewColumn Header="Text" Background="WhiteSmoke" IsSortable="False" IsFilterable="False" Width="45" IsReadOnly="True">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel>
<HyperlinkButton BorderThickness="0" Foreground="#FF034CFF" Margin="4,0,2,0" x:Name="addRowButton" HorizontalAlignment="Right"
Background="Transparent" VerticalAlignment="Top" ToolTipService.ToolTip="Insert new row">
<Image Source="/Toolbox;component/Images/AddRow.png" Height="20"></Image>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
<telerik:GridViewColumn IsSortable="False" IsFilterable="False" Width="30" Background="White" IsReadOnly="True">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<HyperlinkButton BorderThickness="0" Foreground="#FF034CFF" x:Name="deleteRuleInfoRowButton" HorizontalAlignment="Right" Click="deleteRuleInfoRowButton_Click"
Background="Transparent" VerticalAlignment="Top" ToolTipService.ToolTip="Delete">
<Image Source="/Toolbox;component/Images/Delete.png" Height="16"></Image>
</HyperlinkButton>
</StackPanel>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
Thanks-
You can control the order of appearance of the columns using their DisplayIndex property.
Regards,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Show the data!, but don't convert the column to a combobox with the data (enum) options!.
2) And how can I put numerical values ​​on the right side of the column? with AutoGenerateColumns="True" too.
Help me pls!
(SL5 and Telerik 2012.2.607.1050)
My Code here: http://sdrv.ms/SMC5j4
dont know if you still need this solved. For you second point i can give you this:
HowTo: Enabling custom attributes to GridView
Simply use the things described there and use a new custom attribute which uses something like this
public
override
void
UpdateColumn(GridViewColumn column)
{
column.ShowDistinctFilters = DistinctFilters;
column.TextAlignment = TextAlignment.Right;
}
For the first one, i am currently looking into a possibility to change the type of the autogenerated column to a specific one.
Such as the auto generated GridViewDataColumn to GridViewComboBoxColumn and others.
Since some enum types are not converting for me either (especially in their editing modes).