How do I filter dates by yyyy/MM/dd without a DatePicker?

2 posts, 0 answers
  1. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 27 Oct 2010 Link to this post

    I have a RadGrid and have two columns, Start Date and End Date, that displays in standard MM/dd/yyyy format but I need the filtering to be in yyyy/MM/dd format. Otherwise, something like 12/08/2009 evaluates as greater than 04/01/2010 (because it will compare the month values first, not the year values).

    I've looked through several different demos/examples and cannot find the right mix.

    Also, I do not want the DatePicker control to be shown in the filter. I want to use only a textbox with the filter icon visible next to it.

    Here is the relevant portion of my grid:

    <telerik:RadGrid ID="radgrdMyPrograms" runat="server" Width="100%" DataSourceID="ldsProgramsAllByUserName" EnableLinqExpressions="true"
        EnableEmbeddedSkins="false" Skin="DMCpro" ShowStatusBar="true"
        AutoGenerateColumns="false" AllowFilteringByColumn="true" AllowPaging="true" AllowSorting="true" PageSize="20" >
        <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" Scrolling-AllowScroll="true" Scrolling-ScrollHeight="600px" Scrolling-UseStaticHeaders="true" />
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView TableLayout="Fixed" DataKeyNames="ProgramID,ProgramName,ClientId,Client" >
            <HeaderStyle HorizontalAlign="Left" />
            <ItemStyle Font-Size="Small" Wrap="false" />
            <AlternatingItemStyle Font-Size="Small" Wrap="false" />
            <Columns>
                <telerik:GridHyperLinkColumn HeaderText="Program #" DataTextField="ProgramID" SortExpression="ProgramID" UniqueName="ProgramID" 
                    HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="80px" HeaderStyle-HorizontalAlign="Left" AllowFiltering="false" />
                <telerik:GridBoundColumn HeaderText="Program" DataField="ProgramName" SortExpression="ProgramName" UniqueName="ProgramName"
                    HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="150px"
                    AutoPostBackOnFilter="true" ShowFilterIcon="false" FilterControlWidth="150px" />
                <telerik:GridBoundColumn HeaderText="AE" DataField="AEName" SortExpression="AEName" UniqueName="AE"
                    HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="35px" AllowFiltering="false" />
                <telerik:GridDateTimeColumn HeaderText="Start Date" DataField="StartDate" SortExpression="StartDate" UniqueName="StartDate"
                    HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="95px" PickerType="None"
                    AutoPostBackOnFilter="true" FilterControlWidth="65px" />
                <telerik:GridDateTimeColumn HeaderText="End Date" DataField="EndDate" SortExpression="EndDate" UniqueName="EndDate"
                    HeaderStyle-CssClass="radGridViewHeader" HeaderStyle-Width="95px" PickerType="None"
                    AutoPostBackOnFilter="true" FilterControlWidth="65px" />


    BTW, I tried using DataFormatString = "{0:yyyy/MM/dd}" in the GridDateTimeColumns but that has no effect.  I've also tried using just GridBoundColumn instead of GridDateTimeColumn and cannot get it to work either.

    How can I accomplish being able to filter in yyyy/MM/dd format?

    Thanks.
  2. Jerry T.
    Jerry T. avatar
    118 posts
    Member since:
    Jul 2012

    Posted 27 Oct 2010 Link to this post

    *Emily Litella voice*

    Nevermind!



    The problem was in the source Stored Proc.  It was returning a CHAR(10) for the Start Date instead of a datetime. Wrapped that in a CONVERT() and all is well now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top