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

GridDateTimeColumn Special Days

4 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael O'Flaherty
Top achievements
Rank 2
Michael O'Flaherty asked on 23 May 2013, 08:03 PM
Hi!

When we display a RadDatePicker control (see attached #1), we are able to add a special day of "today" using this code:
<telerik:RadDatePicker ID="radDatePickerBirthdateSearchCriteria" MinDate="1/1/1900" runat="server">
    <Calendar ShowRowHeaders="false" runat="server">
        <SpecialDays
            <telerik:RadCalendarDay Repeatable="Today"
                <ItemStyle CssClass="rcToday" /> 
            </telerik:RadCalendarDay
        </SpecialDays
    </Calendar>
</telerik:RadDatePicker>

However, when we display a grid column using this code:
<telerik:GridDateTimeColumn EnableTimeIndependentFiltering="true" DataField="Birthdate" DataFormatString="{0:MM/dd/yyyy}"  HeaderText="Birthdate" SortExpression="Birthdate" UniqueName="Birthdate">
</telerik:GridDateTimeColumn>

protected void radGridResults_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridFilteringItem)
            {
                GridFilteringItem filteringItem = e.Item as GridFilteringItem;
 
                RadDatePicker radDatePicker = (RadDatePicker)filteringItem["Birthdate"].Controls[0];
                radDatePicker.EnableEmbeddedSkins = true;
                radDatePicker.Skin = "Office2010Blue";
                radDatePicker.CssClass = "radDatePicker radGridFilterDatePicker";
                radDatePicker.SharedCalendar.ShowRowHeaders = false;
                Button buttonDatePickerFilter = (Button)filteringItem["Birthdate"].Controls[2];
                buttonDatePickerFilter.CssClass = "rgFilter radGridFilterDatePickerFilterButton";
                RadCalendarDay radCalendarDayToday = new RadCalendarDay();
                radCalendarDayToday.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.Today;
                radCalendarDayToday.ItemStyle.CssClass = "rcToday";
                radDatePicker.Calendar.SpecialDays.Add(radCalendarDayToday);
            }
        }


When we add the special day in code behind, it does not display properly when we are displaying the calendar as a filter (see attached #2.)

Are we doing something wrong? How can we accomplish this?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 May 2013, 08:31 AM
Hi,

Here is the sample code snippet I tried which worked as expected.

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridFilteringItem)
    {
        GridFilteringItem filteringItem = (GridFilteringItem)e.Item;
        RadDatePicker datepicker = (RadDatePicker)filteringItem["Birthdate"].Controls[0];
        datepicker.EnableEmbeddedSkins = true;
        datepicker.Skin = "Office2010Blue";
        datepicker.CssClass = "radDatePicker radGridFilterDatePicker";
        datepicker.SharedCalendar.ShowRowHeaders = false;
        Button buttonDatePickerFilter = (Button)filteringItem["Birthdate"].Controls[2];
        buttonDatePickerFilter.CssClass = "rgFilter radGridFilterDatePickerFilterButton";
        RadCalendarDay NewDay = new RadCalendarDay();
        NewDay.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.Today;
        NewDay.ItemStyle.BackColor = System.Drawing.Color.Bisque;
        datepicker.SharedCalendar.SpecialDays.Add(NewDay);
    }  
}

Thanks,
Shinu.
0
Michael O'Flaherty
Top achievements
Rank 2
answered on 24 May 2013, 12:30 PM
Hmmm... Still no go. I took out the styles just to make sure. C1 is from the grid filter and C2 is from a page. Does the calendar inherit any styles from the grid? Something external must be affecting this. AJAX?

RadDatePicker radDatePicker = (RadDatePicker)filteringItem["Birthdate"].Controls[0];
                radDatePicker.EnableEmbeddedSkins = true;
                //radDatePicker.Skin = "Office2010Blue";
                //radDatePicker.CssClass = "radDatePicker radGridFilterDatePicker";
                radDatePicker.SharedCalendar.ShowRowHeaders = false;
                Button buttonDatePickerFilter = (Button)filteringItem["Birthdate"].Controls[2];
                //buttonDatePickerFilter.CssClass = "rgFilter radGridFilterDatePickerFilterButton";
                RadCalendarDay radCalendarDayToday = new RadCalendarDay();
                radCalendarDayToday.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.Today;
                radCalendarDayToday.ItemStyle.BackColor = System.Drawing.Color.Bisque;
                //radCalendarDayToday.ItemStyle.CssClass = "rcToday";
                radDatePicker.Calendar.SpecialDays.Add(radCalendarDayToday);
0
Accepted
Venelin
Telerik team
answered on 28 May 2013, 10:50 AM
Hi Michael,

The only thing you need to do is to replace this line of code:

radDatePicker.Calendar.SpecialDays.Add(radCalendarDayToday)

with this:

radDatePicker.SharedCalendar.SpecialDays.Add(radCalendarDayToday);

I am also attaching a sample runnable project.

Regards,
Venelin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Michael O'Flaherty
Top achievements
Rank 2
answered on 28 May 2013, 12:51 PM
I keep forgetting about the SharedCalendar vs. Calendar. Not sure I understand why you have it that way, but it works--thanks!
Tags
Grid
Asked by
Michael O'Flaherty
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Michael O'Flaherty
Top achievements
Rank 2
Venelin
Telerik team
Share this question
or