Change the today button label of MonthYear popup since GridDateTimeColumn

2 Answers 84 Views
Calendar DatePicker Grid
Ludovic
Top achievements
Rank 1
Iron
Ludovic asked on 07 Feb 2023, 02:56 PM

I have a RadGrid with a GridDateTimeColumn.

This GridDateTimeColumn has EnableRangeFiltering="true" to display the filter :

<telerik:GridDateTimeColumn DataField="xxx" HeaderText="xxx" AutoPostBackOnFilter="true" 
                    SortExpression="xxx" UniqueName="xxx" PickerType="DatePicker"
                    DataFormatString="{0:D}" EnableRangeFiltering="true" ShowFilterIcon="false">
                </telerik:GridDateTimeColumn>

I have changed the currentCulture of the thread to display calendar in French.

But, if I click on the selected month, I have another popup to choose month and years :

I would like to change the label of the three button "Today", "Ok" and "Cancel".


I have access to the RadDatePicker with the RadGrid OnItemDataBound function, but the following code doesn't work :

protected void RadGrid_OnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
               ...
            } else if (e.Item is GridFilteringItem)
            {
                GridFilteringItem filterItem = e.Item as GridFilteringItem;
                var columns = filterItem.OwnerTableView.RenderColumns
                    .OfType<GridDateTimeColumn>()
                    .Where(x => x.AllowFiltering && x.EnableRangeFiltering);

                System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

                foreach (GridColumn col in columns)
                {
                    ...
                    RadDatePicker picker = filterItem[col.UniqueName].Controls[1] as RadDatePicker;
                    picker.Calendar.FastNavigationSettings.CancelButtonCaption = "Annuler";
                    ...
                }
            }
        }

Someone knows how I can access on this three button in my c# code to change this property ?

 

Thanks

2 Answers, 1 is accepted

Sort by
1
Accepted
Doncho
Telerik team
answered on 10 Feb 2023, 11:36 AM

Hi Ludovic,

We have moved this question to the Telerik ASP.NET for AJAX forum as it was originally opened in the ASP.NET Core.

Now straight to the point:

You have been on the right track with this issue! You will just need to use the SharedCalendar property of the picker instead of the Calendar one:

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        var filteringItem = e.Item as GridFilteringItem;
        //get the picker as the second control in the cell via its index
        var filteringPicker = filteringItem["columnUniqueName"].Controls[1] as RadDatePicker;

        //alternatively you can get the Picker via its predifined built-in ID
        //var filteringPicker = filteringItem["columnUniqueName"].FindControl("RDIPFOrderDate") as RadDatePicker;

        if (filteringPicker != null)
        {
            filteringPicker.SharedCalendar.FastNavigationSettings.TodayButtonCaption = "Aujourd'hui";
            filteringPicker.SharedCalendar.FastNavigationSettings.OkButtonCaption = "J'accepte";
            filteringPicker.SharedCalendar.FastNavigationSettings.CancelButtonCaption = "Annuler";
        }
    }
}
Please give this a try and let me know how it goes.

Kind regards,
Doncho
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ludovic
Top achievements
Rank 1
Iron
answered on 10 Feb 2023, 12:38 PM

Hi Doncho,

Thank you for your answer, it's working like I wish

 

Ludovic

Tags
Calendar DatePicker Grid
Asked by
Ludovic
Top achievements
Rank 1
Iron
Answers by
Doncho
Telerik team
Ludovic
Top achievements
Rank 1
Iron
Share this question
or