Custom Grouping and Searching

4 posts, 0 answers
  1. Ben
    Ben avatar
    2 posts
    Member since:
    Feb 2015

    Posted 19 Jul 2018 Link to this post

    Hi

    I followed the following link to implement custom grouping sorting in my app, however after using the search on the property grid the names of the groups revert to the unformatted names (see the attached Image)

    https://www.telerik.com/forums/custom-grouping-in-propertygrid

    Any Help would be appreciated

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3216 posts

    Posted 20 Jul 2018 Link to this post

    Hello, Ben,    

    Following the provided information and the refereed forum thread for achieving custom grouping in RadPropertyGrid I have prepared a sample project. However, after searching in the toolbar, the group names are preserved as expected on my end . When clearing the search text, the group names are indeed back to default. 

    Note that it is recommended to use the CategoryAttribute which defines the category to which the property will be grouped when properties are shown categorized. Any property that does not have this attribute will be categorized in the Misc category. When you initialize the PropertyStoreItem there is a parameter for the category. However, if you need to customize the category names, you can use the ItemFormatting event. A sample approach is demonstrated in the following code snippet:

    private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
    {
        PropertyGridGroupElement groupElement = e.VisualElement as PropertyGridGroupElement;
        if (groupElement!=null)
        {
            groupElement.TextElement.Text = "category name";
        }
    }

    I am looking forward to your reply.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Ben
    Ben avatar
    2 posts
    Member since:
    Feb 2015

    Posted 21 Jul 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hello Dess

    Thanks for your response. Currently I am using the CategoryAttirbute to define the category of the properties but we also wish to display the categories in a specific order as well.  I have my CategoryAttirbutes set to "01PacomObject_Category_Identification", "02Common_Category_Connection" , and "03Macro_Category_Rules".

    I then use this function (as described in the linked post) to strip the Numeric values from the beginning of the string

    private void GroupDescriptors_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        for (var i = 0; i < Groups.Count; i++)
          Groups[i].Label = Groups[i].Name.Substring(2);
    }

    On Loading of the form it displays correctly without the numeric values, but after the search it has reverted back to what is in the CategoryAttribute.

    The Solution with the ItemFormatting option does work however this is triggered every time something is selected in the grid which is not desirable

     

    Thanks

    Ben

     

     

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3216 posts

    Posted 23 Jul 2018 Link to this post

    Hello, Ben,    

    If you use the CollectionChanged event, the code for renaming the groups will be performed just once when you group the items. However, it is not guaranteed that the names will be kept because after so actions that require refreshing the view, the name will be reset. It is normal that the ItemFormatting event is fired each a lot of times. Its purpose is to provide the correct formatting for the relevant items in RadPropertyGrid. It is also the recommended approach for changing the groups' names. 

    Alternatively, when you add the GroupDescriptor, you can specify the SortDescriptor and which property to control the sort order. For example, when you add the PropertyStoreItem you can specify the Description and the Category. Then, sort the groups the Description:

    You can refer to the following help article demonstrating which are the other criteria by which you can group and sort the groups: https://docs.telerik.com/devtools/winforms/propertygrid/features/grouping 

    I hope this information helps. If you have any additional questions, please let me know.  
     
    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top