I am trying to create a new control by inheriting Radgrid control. I am trying to localize the text "Drag and Drop a column here to group by that column". I created a customlocalizer class to localize and have overriden the base calss method "GetStringOverRide" to override the property "GridviewGroupPanelText" as suggested in the localization documentation on telerik blogs.
The problem is i do not know when to call the below code
LocalizationManager.Manager = new CustomLocalizationManager();
to initialize the localization before UI initialization. Is there some event provided by the radgrid that i can use to initialize the localization. I tried to override the onApplyTemplate but that removes everything else (styling and data).
Any help will be greatly appreciated.
Thanks,
Atin
6 Answers, 1 is accepted
You may assign the custom localization manager to the grid once the page is loaded. Please take a look at this forum thread for a reference.
I hope this is helpful.
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks for the information.
However, my problem is a little bit different than the suggested answer. I am creating a custom control by inheriting radgrid. I want to do the localization of the text in the custom control itself (because this is being used many times) so that i donot have to write the localization code in the pages repeatedly. Does radgrid contain any event that can be used to fire the localization whenever control is loaded or before loading.
Regards,
Atin
In your case then, you could use the DataLoading event of the RadGridView to assign the localization manager.
Regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I tried your suggestion, but no luck. Here is sample code that i am using. I have removed project specific code.
using
System;
using
System.Collections.Generic;
using
System.Collections.Specialized;
using
System.ComponentModel;
using
System.ComponentModel.Composition;
using
System.Linq;
using
System.Windows;
namespace
MyNameSpace
{
public
class
MycustomControl : RadGridView, INotifyPropertyChanged
{
#region Public
public
MycustomControl()
{
if
(!System.ComponentModel.DesignerProperties.IsInDesignTool)
{
CompositionInitializer.SatisfyImports(
this
);
this
.DataLoading +=
new
EventHandler<GridViewDataLoadingEventArgs>(MyCustomControl_DataLoading);
ShowGroupPanel =
false
;
// This property is set to true on the page where this control is placed.
}
}
void
MyCustomControl_DataLoading(
object
sender, GridViewDataLoadingEventArgs e)
{
LocalizationManager.Manager =
new
CustomLocalizationManager();
}
#endregion
}
public
class
CustomLocalizationManager : LocalizationManager
{
public
override
string
GetStringOverride(
string
key)
{
System.Diagnostics.Debugger.Break();
switch
(key)
{
case
"GridViewGroupPanelText"
:
return
"Sample text goes here"
;
}
return
base
.GetStringOverride(key);
}
}
}
Please let me know if there is some other way to do this.
Regards,
Atin
I have tried to test how your code snippet works but I was not able to build the project. That is why I have tested the code using our RadGridView instead of your MycustomControl. As a result the localization text was applied fine.
I noticed that you have ShowGroupPanel =
false
;
Would you please let me know what the result is if you comment this line?
Didie
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks for the updates.
I just realised the code is working fine. Actually we were applying themes on the gridview, so it was overridding the localization as we had also applied the localization in the themes.
Regards,
Atin