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

[Solved] Why RadGrid date picker filter isn’t localized?

1 Answer 161 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex R.
Top achievements
Rank 1
Alex R. asked on 15 Oct 2009, 04:08 PM

Hello.

I try to localize date picker used in RadGrid filter.
The properties I want localize are:
CancelButtonCaption(Button “Cancel” in Calendar popap),
OkButtonCaption (Button “OK” in Calendar popap)
TodayButtonCaption (Button “Today” in Calendar popap)

I’ve tried two solutions:
1. Localize it on Grid ItemCreated event;
2.Localize it on Grid DataBound event.
Code below:
/// <summary> 
/// First solution: Fired when item created. 
/// </summary> 
/// <param name="sender"></param> 
/// <param name="e"></param> 
public void Grid_ItemCreated(object sender, GridItemEventArgs e) { 
  if (e.Item is GridFilteringItem) { 
    GridFilteringItem filter = (GridFilteringItem)e.Item; 
    GridColumn[] renderColumns = e.Item.OwnerTableView.RenderColumns; 
    foreach (GridColumn column in renderColumns) { 
    if (column is GridDateTimeColumn) { 
      RadDatePicker picker = (RadDatePicker)filter[column.UniqueName].Controls[0]; 
      picker.Calendar.FastNavigationSettings.CancelButtonCaption = Resources.GlobalRes.Cancel; 
      picker.Calendar.FastNavigationSettings.OkButtonCaption = Resources.GlobalRes.OK; 
      picker.Calendar.FastNavigationSettings.TodayButtonCaption = Resources.GlobalRes.Today; 
    } 
    } 
 } 
 
//--------------------------------------------------------------- 
 
/// <summary> 
/// Second solution: Is triggered when grid has data bound. 
/// </summary> 
/// <param name="sender"></param> 
/// <param name="e"></param> 
protected void Grid_DataBound(object sender, EventArgs e){ 
GridFilteringItem filteringItem = null
//Get grid filter item. 
if (this.Grid.MasterTableView.GetItems(GridItemType.FilteringItem) != null  
&& this.Grid.MasterTableView.GetItems(GridItemType.FilteringItem).Count() >0) {  
  filteringItem = (GridFilteringItem)this.Grid.MasterTableView.GetItems(GridItemType.FilteringItem)[0]; 
if (filteringItem != null) { 
//Get filter control. 
foreach (GridColumn column in this.Grid.MasterTableView.RenderColumns) { 
  if (column is GridDateTimeColumn) { 
  RadDatePicker picker = (RadDatePicker)filteringItem[column.UniqueName].Controls[0]; 
picker.Calendar.FastNavigationSettings.CancelButtonCaption = Resources.GlobalRes.Cancel; 
picker.Calendar.FastNavigationSettings.OkButtonCaption = Resources.GlobalRes.OK; 
picker.Calendar.FastNavigationSettings.TodayButtonCaption = Resources.GlobalRes.Today; 
                    } 
                } 
            } 
        } 

But this does not help.
Could you help me and give an approach to localize date picker in grid filters?
 
Best regards,
Alex.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 20 Oct 2009, 01:17 PM
Hello Alex,

To get the RadDatePicker instance on ItemCreated event handler (or ItemDataBound respectively) I would suggest you to use the following code:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem item = e.Item as GridFilteringItem;
            RadDatePicker picker = item.FindControl("RadDatePicker1") as RadDatePicker;
        }
    }


Please review the following link for more information about the major differences between ItemDataBound and ItemCreated events:

Distinguishing the major differences between ItemCreated and ItemDataBound events

Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Alex R.
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or