<tGrid:RadGridView x:Name="gridAudioContent" Grid.Row="2" Grid.Column="0" |
CanUserSortColumns="True" |
CanUserReorderColumns="True" |
DataLoadMode="Asynchronous" |
AutoGenerateColumns="False" |
> |
<tGrid:RadGridView.Columns> |
<!-- Play ////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewColumn HeaderText="Play" UniqueName="Play" Width="Auto"> |
<tGrid:GridViewColumn.CellTemplate> |
<DataTemplate> |
<Button Content=">" x:Name="buttonPlay" Click="buttonPlay_Click"></Button> |
</DataTemplate> |
</tGrid:GridViewColumn.CellTemplate> |
</tGrid:GridViewColumn> |
<!-- Track Title //////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewDataColumn HeaderText="Title" IsFilterable="True" IsGroupable="True" UniqueName="TrackTitle" Width="Auto" DataMemberBinding="{Binding View.TrackTitle, Mode=OneTime}" IsReadOnly="True"></tGrid:GridViewDataColumn> |
<!-- Artist ///////////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewDataColumn HeaderText="Artist" UniqueName="Artist" Width="Auto" DataMemberBinding="{Binding View.Artist, Mode=OneTime}" IsReadOnly="True"></tGrid:GridViewDataColumn> |
<!-- Album ////////////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewDataColumn HeaderText="Album" UniqueName="Album" Width="Auto" DataMemberBinding="{Binding View.AlbumTitle, Mode=OneTime}" IsReadOnly="True"></tGrid:GridViewDataColumn> |
<!-- Label ////////////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewDataColumn HeaderText="Label" UniqueName="Label" Width="Auto" DataMemberBinding="{Binding View.Labels, Mode=OneTime}" IsReadOnly="True"></tGrid:GridViewDataColumn> |
<!-- Publisher ////////////////////////////////////////////////////////////////// --> |
<tGrid:GridViewDataColumn HeaderText="Publisher" UniqueName="Publisher" Width="Auto" DataMemberBinding="{Binding View.Publishers, Mode=OneTime}" IsReadOnly="True"></tGrid:GridViewDataColumn> |
</tGrid:GridViewColumns> |
</tGrid:RadGridView> |
this.gridAudioContent.ItemsSource = MyCollectionOfComplexObjects; //Contains Parent objects |
this.gridAudioContent.DataContext = MyCollectionOfComplexObjects; //Contains Parent objects |
15 Answers, 1 is accepted
- ParentObject
- Child Object
- Child Property
public class Flattener : NotifyingObject // base class implements INotifyPropertyChanged |
{ |
public ParentObject Parent {get; set;} |
public Flattener(ParentObject parent) |
{ |
this.Parent = parent; |
} |
public ChildProperty |
{ |
get { return Parent.ChildObject.ChildProperty; } |
set |
{ |
Parent.ChildObject.ChildProperty = value; |
RaisePropertyChanged("ChildProperty"); |
} |
} |
} |
The grid can sort IComparable and group/filter IEquatable<> no matter of the Silverlight version.
Kind regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I have similar issue of lost grouping, sorting, and filtering capability once the column is binded to 2nd tier of the entitycollection.
<telerikGrid:GridViewDataColumn HeaderText="User" DataMemberPath="Person.Username" />
<telerikGrid:GridViewDataColumn HeaderText="Date" DataMemberPath="DateTimeStamp" />
<telerikGrid:GridViewDataColumn HeaderText="Object Name" DataMemberPath="ObjectName" />
<telerikGrid:GridViewDataColumn HeaderText="Comments" DataMemberPath="Comments" />
Column User cann't be grouped, sorted or filtered. And I don't think this has anything to do with what version of the silverlight.
Please help.
Joy
We have similar example with sub properties however everything works fine. Can you send us an example where this can be reproduced?
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Thanks for your example.
Instead of adding GridViewDataColumns in xaml,
<telerikGrid:RadGridView x:Name="_gridResults" IsReadOnly="True" RowIndicatorVisibility="Visible" AutoGenerateColumns="False" ColumnsWidthMode="Fill" CanUserFreezeColumns="True" Margin="5,0,5,5"
ItemsSource="{Binding DependencyProperties.HistoryNoteList, Mode=TwoWay}">
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewDataColumn HeaderText="User" UniqueName="Person.Username" />
<telerikGrid:GridViewDataColumn HeaderText="Date" UniqueName="DateTimeStamp" />
<telerikGrid:GridViewDataColumn HeaderText="Action" UniqueName="HistoryNoteAction.HistoryNoteAction" />
<telerikGrid:GridViewDataColumn HeaderText="Object" UniqueName="ApplicationLevel.ApplicationLevel" />
<telerikGrid:GridViewDataColumn HeaderText="Object Name" UniqueName="ObjectName" />
<telerikGrid:GridViewDataColumn HeaderText="Comments" UniqueName="Comments" />
</telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>
I added all my columns in cs file, and all my columns can be grouped, sorted and filtered.
private void AddColumnsForHistoryNotes()
{
this._gridResults.AutoGenerateColumns = false;
this._gridResults.Columns.Add(CreateColumn(typeof(string), "User", "Person.Username"));
this._gridResults.Columns.Add(CreateColumn(typeof(DateTime), "Date", "DateTimeStamp"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Action", "HistoryNoteAction.HistoryNoteAction"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Object", "ApplicationLevel.ApplicationLevel"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Object Name", "ObjectName"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Comments", "Comments"));
}
private static GridViewDataColumn CreateColumn(Type columnType, string header, string dataPath)
{
GridViewDataColumn column = new GridViewDataColumn();
column.DataType = columnType;
column.UniqueName = dataPath;
column.HeaderText = header;
return column;
}
The question is why can't I accomplish this through xaml? Is it because I did not set DataType in xaml? If so, what is the syntax of set DataType in xaml? FYI, my GridView ItemsSource is a ObservavleCollection.
Please explain!
Thanks,
Joy
After more testing, I found all three columns(User, Action and Object), which binded to sub properties and created in cs file, can be sorted and filtered for a couple of times after the page was loaded, after that, only grouping work on these columns, sorting and filtering were no longer work.
The other columns works fine.
Please help!
Joy
Thanks for your example.
Instead of adding GridViewDataColumns in xaml,
<telerikGrid:RadGridView x:Name="_gridResults" IsReadOnly="True" RowIndicatorVisibility="Visible" AutoGenerateColumns="False" ColumnsWidthMode="Fill" CanUserFreezeColumns="True" Margin="5,0,5,5"
ItemsSource="{Binding DependencyProperties.HistoryNoteList, Mode=TwoWay}">
<telerikGrid:RadGridView.Columns>
<telerikGrid:GridViewDataColumn HeaderText="User" UniqueName="Person.Username" />
<telerikGrid:GridViewDataColumn HeaderText="Date" UniqueName="DateTimeStamp" />
<telerikGrid:GridViewDataColumn HeaderText="Action" UniqueName="HistoryNoteAction.HistoryNoteAction" />
<telerikGrid:GridViewDataColumn HeaderText="Object" UniqueName="ApplicationLevel.ApplicationLevel" />
<telerikGrid:GridViewDataColumn HeaderText="Object Name" UniqueName="ObjectName" />
<telerikGrid:GridViewDataColumn HeaderText="Comments" UniqueName="Comments" />
</telerikGrid:RadGridView.Columns>
</telerikGrid:RadGridView>
I added all my columns in cs file, and all my columns can be grouped, sorted and filtered.
private void AddColumnsForHistoryNotes()
{
this._gridResults.AutoGenerateColumns = false;
this._gridResults.Columns.Add(CreateColumn(typeof(string), "User", "Person.Username"));
this._gridResults.Columns.Add(CreateColumn(typeof(DateTime), "Date", "DateTimeStamp"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Action", "HistoryNoteAction.HistoryNoteAction"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Object", "ApplicationLevel.ApplicationLevel"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Object Name", "ObjectName"));
this._gridResults.Columns.Add(CreateColumn(typeof(string), "Comments", "Comments"));
}
private static GridViewDataColumn CreateColumn(Type columnType, string header, string dataPath)
{
GridViewDataColumn column = new GridViewDataColumn();
column.DataType = columnType;
column.UniqueName = dataPath;
column.HeaderText = header;
return column;
}
The question is why can't I accomplish this through xaml? Is it because I did not set DataType in xaml? If so, what is the syntax of set DataType in xaml? FYI, my GridView ItemsSource is a ObservavleCollection.
Please explain!
Thanks,
Joy
Posted 19 hours ago (permalink)
After more testing, I found all three columns(User, Action and Object), which binded to sub properties and created in cs file, can be sorted and filtered for a couple of times after the page was loaded, after that, only grouping work on these columns, sorting and filtering were no longer work.
The other columns works fine.
Please help!
I have the same problem and it really frastrating. I'm a new telerik silverlight user please advise, and post a litle demo app if you can. I'm sorry but I cant follow on the online telerik demo. here is my gridview though:
<telerikGridView:RadGridView.Columns> |
<telerikGridView:GridViewDataColumn Width="50" HeaderText="ID" DataMemberPath="ID" /> |
<telerikGridView:GridViewDataColumn Width="250" HeaderText="Client Name" DataMemberPath="ClientName" /> |
<telerikGridView:GridViewDataColumn Width="250" HeaderText="Account Manager" DataMemberPath="AccountManager.FullName"/> |
<telerikGridView:GridViewDataColumn Width="60" HeaderText="Archived" DataMemberPath="Archived" /> |
</telerikGridView:RadGridView> |
I can sort fine on "ID", "ClientName" and "Archived". but I cant sort on "Account Manager", now this is happening on all the grids on my App, I think its because its linked Columns (i.e AccountManager.FullName)
Thanks in advance.
Nathi
We had such issue in the past however this was fixed. Please try our latest build!
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Issue is still present, using the latest beta '2009_3_1019' or internal build 'Beta2_2009_3_1023'.
Cheers,
Jani
Can you post an example where this can be reproduced with our latest version?
Kind regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
It turns out we are facing very similar problem.
We have a collection of business objects which we then bind to a grid view.
The business object has some properties and also has a reference to another object.
i.e.
public class BusinessObject
{
public int RowSequence { get; set; }
public int VersionNumber { get; set; }
public BaseConfig Config { get; set; }
}
Please note that the 'BaseConfig' is just the base class and the value of the Config property equals to a derived class (i.e. DeriveConfig1, DerivedConfig2).
The gridView is bound to the RowSequence and the VersionNumber but we also need to bind the properties of 'BaseConfig' (which are different in each derived class). We have managed to build the columns dynamically (using reflection) and set the Header, DataMemberBinding, DataType, UniqueName of each GridViewDataColumn.
All is well until Filter is applied on the columns of the 'Config'. It throws an exception 'Invalid property or field 'Config' for type 'BaseConfig'. Investigating the problem through Reflector we found you use declared type not the runtime type to filter underlying collection:
Telerik.Windows.Data.ItemPropertyInfoHelper :
private static PropertyDescriptorCollection GetPropertyDescriptors(QueryableCollectionView collectionView)
{
return TypeDescriptor.GetProperties(collectionView.ElementType);
}
meaning gridView does not support the scenario we are trying to implement. Could you please confirm this is the case or if there are any workarounds / possible fix?
Kind Regards
Milosz / Semi
You are right. We resolve property type based on the object types, so derived object properties cannot be resolved correctly. One of the workarounds you can currently implement is to create a custom view model that wraps your business object and use it for binding. The other workaround is to create a custom column for your BaseConfig type and implement the different logic for your derived types in this custom column.
All the best,
Stefan Dobrev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thank you for the confirmation and suggested workarounds. Are you planning to support similar scenarios in future releases?
Kind Regards
Milosz
We will definitely try to handle scenarios like this in the future. Actually I have put this in our product backlog, but its priority is not very high right now. Maybe we will try to address this in post 2010 Q1 time frame.
Best wishes,
Stefan Dobrev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.