Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

The A-Z button doesn't make the grid sort the properties alphabetically

$
0
0

Yes, but when working with A-Z, any user would expect the properties to be ordered from A-Z, and not just appear as they are not, but without the groups header (Look on how visual studio implements its property grid).

 

Anyway, since you are not giving me a solution, then I had to look for one myself. It involves changing the source code, but since I already must recompile the source code since your License agreement enforces me to do so (Protecting your assembly by uncommenting some code in the assembly protection). It is just a headache to maintain the changes (and some fixes) when a new Rad Controls version is released.

If anyone is interested in a solution, then find a converter named: FlatItemSourceConverter

Then change its code to:

publicclassFlatItemSourceConverter : IValueConverter
{
    /// <summary>
    /// Sifts out the root properties.
    /// </summary>
    publicobjectConvert(objectvalue, Type targetType, objectparameter, System.Globalization.CultureInfo culture)
    {
        var currentIEnumerable = value asIEnumerable<PropertyDefinition>;
        if(currentIEnumerable != null&& currentIEnumerable.IsNotEmpty())
        {
            if(currentIEnumerable.ElementAt(0).ParentPropertyGrid != null&& currentIEnumerable.ElementAt(0).ParentPropertyGrid.IsGrouped)
            {
                var res = currentIEnumerable.AsQueryable<PropertyDefinition>()
                .Where(newFilterDescriptorCollection() { newFilterDescriptor() { Member = "IsFiltered", Operator = FilterOperator.IsEqualTo, Value = true} })
                .Sort(newSortDescriptorCollection() { newSortDescriptor() { Member = "OrderIndex"}, newSortDescriptor() { Member = "DisplayName"} });
                returnres;
            }
            else
            {
                var res = currentIEnumerable.AsQueryable<PropertyDefinition>()
                .Where(newFilterDescriptorCollection() { newFilterDescriptor() { Member = "IsFiltered", Operator = FilterOperator.IsEqualTo, Value = true} })
                .Sort(newSortDescriptorCollection() { newSortDescriptor() { Member = "DisplayName"} });
                returnres;
            }
        }
        returnvalue;
    }
 
    /// <summary>
    /// Not used.
    /// </summary>
    publicobjectConvertBack(objectvalue, Type targetType, objectparameter, System.Globalization.CultureInfo culture)
    {
        thrownewNotImplementedException();
    }
 
    privatestaticIFilterDescriptor SearchFilterDescriptor { get; set; }
}

 

By this way, the properties are ordered alphabetically when the properties are not grouped, and by OrderIndex and then alphabetically (if few properties share the same OrderIndex) if grouped.

 

And as a remark, the thread that you've mentioned is called "How to disable alphabetical sort in the grouped view", and not "How to disable alphabetical soft". People were specifically asking to disable the alphabetical sorting, and giving controlled order in the grouped view only.


Viewing all articles
Browse latest Browse all 78072

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>