Hide row header of filter RadDatePicker

12 posts, 1 answers
  1. Ruchi
    Ruchi avatar
    13 posts
    Member since:
    Apr 2011

    Posted 26 Jun 2013 Link to this post

    Hi All,

    I am using GridDateTime Column in rad gridview and I want to change calender property of filter rad date time picker. I tried to do it like below way but its not working 

    protected void dgTest_ItemCreated(object sender, GridItemEventArgs e)
       {
           if (e.Item.ItemType == GridItemType.FilteringItem)
           {
               GridFilteringItem filterItem = (GridFilteringItem)e.Item;
               RadDatePicker startDate = (RadDatePicker)filterItem["StartDate"].FindControl("RDIPFStartDate");
               startDate.Calendar.ShowRowHeaders = false;
           }
       }

    Can anyone help me?.. Its urgent

    Thanks in advance
    Ruchi Jani
  2. Answer
    Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 01 Jul 2013 Link to this post

    Hello Ruchi,

    Thank you for contacting us.

    Please note that the auto-generated pickers for filtering GridDateTimeColumns use SharedCalendar. Therefore, you will need to slightly modify your code:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridFilteringItem)
        {
            GridFilteringItem filterItem = e.Item as GridFilteringItem;
            RadDatePicker picker = filterItem["StartDate"].Controls[0] as RadDatePicker;
            picker.SharedCalendar.ShowRowHeaders = false;
        }
    }

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 04 Nov 2013 Link to this post

    How to set  raddatepicker.calendar.ShowRowHeader=false for all raddatepicker throughout  my website?
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2013 Link to this post

    Hi THANGARAI,

    Please try the following code snippet to achieve your scenario.

    Create a RadDatePickerAdapter.cs inside App_Code folder.
    RadDatePickerAdapter.cs:
    using System;
    using System.Web.UI.Adapters;
    using Telerik.Web.UI;
     
    /// <summary>
    /// Summary description for RadDatePickerAdapter
    /// </summary>
    public class RadDatePickerAdapter : ControlAdapter
    {
        protected override void OnLoad(EventArgs e)
        {
            var datepicker = this.Control as RadDatePicker;
            if (datepicker != null)
            {
                datepicker.Calendar.ShowRowHeaders = false;
            }
            base.OnLoad(e);
        }
    }

    Create a default.browser inside App_Browsers folder.
    default.browser:
    <browser refID="Default">
      <controlAdapters>
        <adapter
          controlType="Telerik.Web.UI.RadDatePicker"
          adapterType="RadDatePickerAdapter"
        />
      </controlAdapters>
    </browser>
     
    ASPX:
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    </telerik:RadDatePicker>

    Thanks,
    Princy.

     
  6. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 05 Nov 2013 Link to this post

    Hi Princy,
        Thanks for your reply Its works great. But its not working for the RadDatePickers inside the RadGrid 
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Nov 2013 Link to this post

    Hi THANGARAI,

    Unfortunately I couldn't replicate the issue at my end. Please have a look into the code snippet to hide the RowHeader of RadDatePicker which is inside the RadGrid. Please try to add the RadDatePickerAdapter.cs in App_Code folder and default.browser in App_Browsers folder.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
        ShowFooter="true">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID" HeaderText="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID" HeaderText="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ShipAddress" UniqueName="ShipAddress" HeaderText="ShipAddress">
                </telerik:GridBoundColumn>
                <telerik:GridTemplateColumn HeaderText="DatePicker">
                    <ItemTemplate>
                        <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
                        </telerik:RadDatePicker>
                        <telerik:RadDatePicker ID="RadDatePicker2" runat="server">
                        </telerik:RadDatePicker>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
        SelectCommand="SELECT top 2 [OrderID], [CustomerID], [ShipAddress] FROM [Orders]">
    </asp:SqlDataSource>

    Hope this will helps you.
    Thanks,
    Princy.
  8. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 06 Nov 2013 Link to this post

    Hi Princy,
    Thanks for your reply.
    Unfortunately we have many screens having RadGrid with gridbound column i cant change all those to grid item template columns. Please give some other solution which is feasible.

    Please find my attachment.
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Nov 2013 Link to this post

    Hi THANGARAI,

    I guess you are using GridDateTimeColumn then please try the following code snippet which works fine at my end. If you are using GridBoundColumn then the above solution works perfectly.

    ASPX:
    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false"
        ShowFooter="true" AllowFilteringByColumn="true">
        <MasterTableView>
            <Columns>
                <telerik:GridBoundColumn DataField="OrderID" UniqueName="OrderID" HeaderText="OrderID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="CustomerID" UniqueName="CustomerID" HeaderText="CustomerID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="OrderDate" UniqueName="OrderDate" HeaderText="OrderDate"
                    DataType="System.DateTime">
                    <FilterTemplate>
                        <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
                        </telerik:RadDatePicker>
                    </FilterTemplate>
                </telerik:GridBoundColumn>
                <telerik:GridDateTimeColumn DataField="OrderDate" UniqueName="Date">
                </telerik:GridDateTimeColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    RadDatePickerAdapter.cs:
    public class RadDatePickerAdapter : ControlAdapter
    {
        protected override void OnLoad(EventArgs e)
        {
            var Calendar = this.Control as RadCalendar;
            if (Calendar != null)
            {
                Calendar.ShowRowHeaders = false;
            }
            base.OnLoad(e);
        }
    }

    default.browser :
    <browser refID="Default">
      <controlAdapters>
        <adapter
          controlType="Telerik.Web.UI.RadCalendar"
          adapterType="RadDatePickerAdapter"
        />
      </controlAdapters>
    </browser>

    Hope this will helps you.
    Thanks,
    Princy.
  10. THANGARAI
    THANGARAI avatar
    21 posts
    Member since:
    Nov 2013

    Posted 11 Nov 2013 Link to this post

    Thank you Princy,
    Its working great.Thanks a lot. It saved more time.
  11. Ben
    Ben avatar
    5 posts
    Member since:
    Jan 2015

    Posted 14 Apr 2015 in reply to Princy Link to this post

    Princy,

    I am using a GridDateTimeColumn and having uses implementing this recommendation. Can you reply or email me with more specifics (benj9515@gmail.com)? Where should the "default.browser" code go? Do I need to make a new class for "RadDatePickerAdapter.cs"? Thanks

  12. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 17 Apr 2015 Link to this post

    Hello Ben,

    If you have difficulties implementing this approach, I suggest that you open a formal support ticket and provide detailed explanation about what exactly you want to achieve.

    Regards,
    Eyup
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  13. Ben
    Ben avatar
    5 posts
    Member since:
    Jan 2015

    Posted 17 Apr 2015 Link to this post

    Thanks Eyup. I found the issue on my end. Solution works.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017