RadGridLocalizationProvider : custom GroupingPanelDefaultMessage

6 posts, 0 answers
  1. Tim R
    Tim R avatar
    132 posts
    Member since:
    Feb 2006

    Posted 19 Nov 2012 Link to this post


    I want to give each of my grids a custom GroupingPanelDefaultMessage based on which column(s) is/are groupable.  For example,

    "To show sales grouped by Division, drag that column-header here".

    I hope it is not necessary to create a custom LocalizationProvider for each such customization. Is it? If so, the following doc doesn't provide enough info:

    http://www.telerik.com/help/winforms/gridview-localization.html

    I don't see an object called RadGridLocalizationProvider anywhere. 
    Is the RadGridLocalizationProvider an  object encapsulated by the grid?


    Thanks

  2. Anton
    Admin
    Anton avatar
    167 posts

    Posted 22 Nov 2012 Link to this post

    Hello Tim,

    Thank you for contacting Telerik support.

    You can achieve the desired functionality and without a RadGridLocalizationProvider - just access the GroupPanaleElement from the element tree and set the text that you want. For example:
    this.radGridView1.GridViewElement.GroupPanelElement.Text = "Your Custom text 1";

    Attached is a sample project that comprises the code above.

    I hope this helps.

    Kind regards,
    Anton
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  3. Tim R
    Tim R avatar
    132 posts
    Member since:
    Feb 2006

    Posted 27 Nov 2012 Link to this post

    Thank you, Anton.  But this simple and easy solution is not working for me.  I stepped through my code in the debugger to make sure the code was being executed. The following assignment of the .Text property has no visible effect when the grid is rendered; the original default text still appears there in the group panel:

         grid.GridViewElement.GroupPanelElement.Text = "To group by department, drag the [dept] column here";

    But the following slightly different code superimposes my custom text onto the generic text (you can see both messages);

        grid.GridViewElement.GroupPanelElement.Panel.Text = "To group by department, drag the [dept] column here";

    If you could please confirm that the solution you suggested works as expected on your computer, I can try to find out why it's not working for me. Possibly a version difference? I'm using the Q3 2012 evaluation.


     
  4. Anton
    Admin
    Anton avatar
    167 posts

    Posted 30 Nov 2012 Link to this post

    Hello Tim,

    Thank you for writing back.

    The code that I provided works just fine on my end with the latest version.

    I have further extended the provided example by subscribing to the GroupByChanged event to handle the case when user clears the groups, as this is a case where the grid will reset the text:
    private void Form1_Load(object sender, EventArgs e)
    {
        DataTable listTable = new DataTable();
        listTable.Columns.Add("Name");
        listTable.Columns.Add("Busy");
        listTable.Columns.Add("Id");
     
        listTable.Rows.Add("Saraha", "No", 1);
        listTable.Rows.Add("Joe", "No", 2);
        listTable.Rows.Add("Lisa", "Yes", 3);
        listTable.Rows.Add("George", "No", 4);
        listTable.Rows.Add("Mary", "Yes", 5);
        listTable.Rows.Add("Janet", "No", 6);
     
        this.radGridView1.DataSource = listTable;
        this.radGridView2.DataSource = listTable;
     
        this.radGridView1.GridViewElement.GroupPanelElement.Text = "Your Custom text 1";
        this.radGridView2.GridViewElement.GroupPanelElement.Text = "Your Custom text 2";
     
        this.radGridView1.GroupByChanged += new GridViewCollectionChangedEventHandler(radGridView1_GroupByChanged);
        this.radGridView2.GroupByChanged += new GridViewCollectionChangedEventHandler(radGridView2_GroupByChanged);
    }
     
    void radGridView1_GroupByChanged(object sender, GridViewCollectionChangedEventArgs e)
    {
        if (e.GridViewTemplate.GroupDescriptors.Count == 0)
        {
            this.radGridView1.GridViewElement.GroupPanelElement.Text = "Your Custom text 1";
        }
    }
     
    void radGridView2_GroupByChanged(object sender, GridViewCollectionChangedEventArgs e)
    {
        if (e.GridViewTemplate.GroupDescriptors.Count == 0)
        {
            this.radGridView2.GridViewElement.GroupPanelElement.Text = "Your Custom text 2";
        }
    }

    There is no need to use grid.GridViewElement.GroupPanelElement.Panel.Text. 

    I hope this helps.

    All the best,
    Anton
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  5. Will
    Will avatar
    6 posts
    Member since:
    Apr 2008

    Posted 13 Dec 2018 in reply to Anton Link to this post

    What is the 2018 solution for this issue?  It appears that radGridView.GridViewElement has been depreciated.  Thanks!
  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3568 posts

    Posted 14 Dec 2018 Link to this post

    Hello, Will,     

    The GridViewElement property is not deprecated in the latest version. In order to change the text of the group panel, it is suitable to use a RadGridLocalizationProvider and specify the desired text for the RadGridStringId.GroupingPanelDefaultMessage. Please refer to the following help article demonstrating how to create and apply a localization provider: https://docs.telerik.com/devtools/winforms/controls/gridview/localization/localization

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top