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

GirdDateTime Column Max Date

2 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dustin Dodson
Top achievements
Rank 1
Dustin Dodson asked on 21 Jan 2011, 07:31 PM
I have been trying to get this to work forever now.. is there something that I am just not seeing.

I am trying to set the max date from the code behind and it's just not cooperating... yet everything else is.

Here's the code behind in the item_created method:
if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
            {               
                GridEditFormItem dataItem = e.Item as GridEditFormItem;
                TableCell cell = dataItem["InspectionDate"];
                RadDatePicker rdp = cell.Controls[0] as RadDatePicker;
                rdp.Calendar.UseColumnHeadersAsSelectors = false;
                rdp.Calendar.UseRowHeadersAsSelectors = false;              
                rdp.MaxDate = DateTime.Now;
           }
 
any ideas would be great... basically it can figure out that the date is too large if you pick past the date, but when the calendar pops up, the dates past today are not grayed out... If I set the max date manually in the markup, it works fine.

please let me know if you need any more info.

Thanks,

Dustin

2 Answers, 1 is accepted

Sort by
0
Dustin Dodson
Top achievements
Rank 1
answered on 24 Jan 2011, 04:36 PM
OK I have found something else that might hopefully shed some light on what's going on. In the previous post I am setting the UseColumnHeadersAsSelectors = false, same with the rows... well when the calendar first pops up it will highlight the whole row/column if I mouse over it. But if I go to the next month with the calendar pager at the top of the control, it won't do it any more. Like the settings didn't take affect until it refreshed or something.

Sadly this still is not fixing my max date problem. I need it to gray out anything that is past DateTime.Now

Please any help or thoughts with this would be great.

Thanks,

Dustin
0
Marin
Telerik team
answered on 26 Jan 2011, 05:58 PM
Hello Dustin,

For your case with GridDateTimeColumn you should use the SharedCalendar property of the RadDatePicker instead of Calendar. The SharedCalendar property holds a shared instance of the calendar in order to speed up performance when we use the calendar on many places. This is the case with the grid having multiple items each having a calendar, that is why the GridDateTimeColumn makes use of the SharedCalendar property instead of the standard one. Also here the relevant property for the maximum date is called RangeMaxDate. Finally the change in the code should be:

RadDatePicker rdp = cell.Controls[0] as RadDatePicker;
rdp.SharedCalendar.UseColumnHeadersAsSelectors = false;
rdp.SharedCalendar.UseRowHeadersAsSelectors = false;
rdp.SharedCalendar.RangeMaxDate = DateTime.Now;


Greetings,


Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Dustin Dodson
Top achievements
Rank 1
Answers by
Dustin Dodson
Top achievements
Rank 1
Marin
Telerik team
Share this question
or