i was using Q3 2009 and i populate my RadGridView with a Datatable of Dynamically generated classes.
I used to have one of the Datatable columns with Type "object" which contains a stackpanel with image +Text data and the RadGridView was displaying it fine.
But after i have updated to Q1 2010 the RadGridView just displays the Type Text,
- Code Used:
StackPanel contentPanel = new StackPanel() { Orientation = Orientation.Horizontal };
TextBlock contentText = new TextBlock() { TextAlignment = TextAlignment.Center, Text = "Video"};
Image contentImage = new Image() { VerticalAlignment = VerticalAlignment.Top, Height = 20, Width = 20 };
contentImage.Source =
new BitmapImage(new Uri(@"Images/video.png", UriKind.Relative));
contentPanel.Children.Add(contentImage);
contentPanel.Children.Add(contentText);
datatable.Columns.Add(
new DataColumn() { ColumnName = xmlFields.Name.LocalName, DataType = typeof(object) });
datarow[xmlFields.Name.LocalName]=contentPanel;
this.radGridView.ItemsSource = datatable;
All i want is to set the cell content as Image+Text,
Is there a other way to set Customized (Image+Text)Cell content when the columns that are dynamically created?
i have attached a screen shot which explains better..
Kindly do the needful.
Thanks and Regards
Dominic savio.M
6 Answers, 1 is accepted
Please add desired UI elements and/or templates to the grid instead DataTable! You can use CellTemplate and/or CreateCellElement in inherited column to achieve this.
Sincerely yours,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
But it was working with Q3 2009 , do i have to change the logics for every version Updates..!
any way,
could you please give an simple example regarding how to set a cell template programatically(not in Xaml),
because i dosent have Columns created in xaml , they are created at run time.
Thank you
Dominic savio.M
You don't have to change your logic for common things however UI as a part of your data layer is a bit unusual - in my opinion this was supported incidentally.
You can assign CellTemplate in exactly the same way as in XAML:
column.CellTemlate = (DataTemplate)this.Resource["YourTemplate"];
If you want to instantiate DataTemplate programmatically you can use XamlReader.Load(). The other option will be (as I said in my previous reply) to inherit from desired column, override CreateCellElement and return desired FrameworkElement.
All the best,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
am working on the Cell template, i do have one more issue regarding setting background of theTop left Header Cell above the indicator ,i have posted it twice still havent got any reply..
could you please help me with that..
Thanks and regards
Dominic savio.M
Hi,
i have identified the problem with setting background to TopLeftHeaderCell,
when i have a theme applied to the Application the GridViewHeaderRowStyle is not getting applied.
Example:
when i have
StyleManager.ApplicationTheme = ThemeManager.FromName("Vista");
the below code is not effective
<Style x:Key="GridViewHeaderRowStyle" TargetType="gridView:GridViewHeaderRow">
<Setter Property="Background" Value="Red" />
</Style>
how can i fix this?
I believe this was covered in another forum post of yours. In any case please review this post which illustrates how to go about restyling the header and let me know if you need any additional assistance.
Please lets keep this conversation in only one forum thread.
Greetings,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.