Tuesday, February 18, 2014

How to Remove Week Numbers from the GridDateTimeColumn/ RadDatePicker in Telerik Grid.

Hi all,

You may have used the date pickers from Telerik controls, either in RadGrid’s GridDateTimeColumn or in RadDatePicker. In both of these scenarios, by default the Telerik control will add a week column from the side of the calendar. Following is the calendar with week columns.




But for some applications we don’t need this column and we will want to remove it. So following is the way that you can achieve that.

The first approach is to remove the week column from the GridDateTimeColumn in RadGrid.

<telerik:GridDateTimeColumn UniqueName="Column2" Visible="true" 
DataFormatString="{0:MM/dd/yyyy}">
                <ItemStyle Wrap="true" />
                <HeaderStyle VerticalAlign="Top" />
</telerik:GridDateTimeColumn>


protected void GridFourColumns_ItemDataBound(object sender, GridItemEventArgs e)
        {           
           RadDatePicker date2 = editItem["Column2"].Controls[0] as RadDatePicker;
           if (date2 != null)
           {
              date2.SharedCalendar.ShowRowHeaders = false;
           }               
           
        }

The following approach is to remove the week column from the RadDatePicker.

 <telerik:RadDatePicker ID="dtpStartDate" runat="server"
      <Calendar ShowRowHeaders="false"></Calendar> 
 </telerik:RadDatePicker> 

Following is the final output without week columns.



Hope this will be helpful.
Thanks J

No comments:

Post a Comment