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.