This is a migrated thread and some comments may be shown as answers.

SortDescriptors for RadPropertyGrid?

3 Answers 106 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Inseok
Top achievements
Rank 1
Inseok asked on 13 Jul 2011, 06:58 AM
Hi,
It's very pleasure to meet RadPropertyGrid in Q2.
It would be even better if It provides 'custom sort' by some property say, 'SortDescriptors' or something.
In my scenario, most of properties need to be sorted by its priority as a default.
Imagine, how awkward if the 'Name' property displayed at the bottom of properties for some entity?

Anyway, is there any chance to customize sorting behavior in the release version of Q2 2011?

Oh~ BTW, I made a small customization to do above, using GroupingItemsSourceConverter.
I hope it will be supported by built-in component in Q2'11.
Here's some snippets for others, just in case.

First, I made a derived class from PropertyDefinition for ordering:
public class OrderedPropertyDefinition : PropertyDefinition
{
    #region Order
    /// <summary>
    /// Identifies the Order dependency property.
    /// </summary>
    public static readonly DependencyProperty OrderProperty = DependencyProperty.Register("Order", typeof(int), typeof(OrderedPropertyDefinition), null);
 
    /// <summary>
    /// Gets or sets the Order possible Value of the int object.
    /// </summary>
    public int Order
    {
        get { return (int)GetValue(OrderProperty); }
        set { SetValue(OrderProperty, value); }
    }
    #endregion Order
}

Second, a CustomGroupItemsSourceConverter for the 'Grouping Mode':
public class CustomGroupingItemsSourceConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        QueryableCollectionView qcv = new QueryableCollectionView((IEnumerable)value);
        GroupDescriptor descriptor = new GroupDescriptor();
        descriptor.Member = "GroupName";
        qcv.GroupDescriptors.Add(descriptor);
        // TODO: get SortDescriptors outside of this converter.
        qcv.SortDescriptors.Add(new SortDescriptor { Member = "Order" });
        return qcv.Groups;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}
I only added a line of code which adds SortDescriptor to the QuaryableCollectionView.

Finally, I edited a copy of default Template of RadPropertyGrid, to make the "groupTemplate" uses my CustomGroupingItemsSourceConverter:
<local:CustomGroupingItemsSourceConverter x:Key="CustomGroupingItemsSourceConverter" />
 
<!-- ... -->
<telerik:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<!--<telerik:GroupingItemsSourceConverter x:Key="GroupingItemsSourceConverter"/>-->
    <DataTemplate x:Key="groupTemplate">
    <!--<ItemsControl ItemsSource="{Binding ., Converter={StaticResource GroupingItemsSourceConverter}}">-->
    <ItemsControl ItemsSource="{Binding ., Converter={StaticResource CustomGroupingItemsSourceConverter}}">
<!-- ... -->

As the result, I could see the properties ordered by its priority(order property), as I wished. :D

Regards,
Inseok

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 14 Jul 2011, 03:43 PM
Hello Inseok,

Thank you for the nice words and the feature request. We are definitely going to consider adding such functionality for our very next Official Release.

The approach you have demonstrated is really a nice one and I would recommend it to anyone  in a need of custom sorting until we have this implemented. ( .e.g. for the Service pack ).

One more time thank you for your valuable feedback . I am updating your Telerik points.

All the best,
Pavel Pavlov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
ramesh
Top achievements
Rank 1
answered on 18 Oct 2011, 07:14 AM
HI, Pavel Pavlov
I have one problem with radpropertyGrid,
 i.e
when i opened the propertyGrid in group mode and 

i will try to add some collection of data to radpropertygrid(before adding the data am clear the data)

it does't shows the data in groupmode(it still open in group mode), but data is there in the normal mode

...once i cleck the normal mode and back to group mode it shows the data...

i don't know wat is the problem..plz help me

and also how to update (or) refresh the RadpropertyGrid?
0
Joël
Top achievements
Rank 2
answered on 24 Jan 2012, 11:12 AM
Is is possible to have a complete example of the implementation because I can not.
Tags
General Discussions
Asked by
Inseok
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
ramesh
Top achievements
Rank 1
Joël
Top achievements
Rank 2
Share this question
or