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

RadGridLocalizationProvider : custom GroupingPanelDefaultMessage

5 Answers 83 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tim R
Top achievements
Rank 1
Tim R asked on 19 Nov 2012, 07:13 PM

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

5 Answers, 1 is accepted

Sort by
0
Anton
Telerik team
answered on 22 Nov 2012, 03:18 PM
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.
0
Tim R
Top achievements
Rank 1
answered on 27 Nov 2012, 12:17 PM
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.


 
0
Anton
Telerik team
answered on 30 Nov 2012, 07:32 AM
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.
0
Will
Top achievements
Rank 1
answered on 13 Dec 2018, 03:31 PM
What is the 2018 solution for this issue?  It appears that radGridView.GridViewElement has been depreciated.  Thanks!
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 14 Dec 2018, 09:44 AM
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.
Tags
GridView
Asked by
Tim R
Top achievements
Rank 1
Answers by
Anton
Telerik team
Tim R
Top achievements
Rank 1
Will
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or