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

Filtering with other date format don't work

1 Answer 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hans van Rijnswoud
Top achievements
Rank 2
Hans van Rijnswoud asked on 30 Mar 2009, 09:30 AM
Hi,

We use in the Grid different column with the date format : dd-MM-yyyy (01-02-2009).
The standard filtering don't work.
I read different post and the documentation ( with many broken links) about this problem but i don't found any solution.

Do you have a nice sample to implement the filter with different format date who's work.
I use for the date only the filter Equal To.

Bellow my code:

     <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Office2007" 
                        GridLines="None" PageSize="13" Height="455px" OnNeedDataSource="RadGrid1_OnNeedDataSource" 
                        AutoGenerateColumns="false" OnInit="RadGrid_Init" AllowSorting="true" AllowPaging="true" EnableViewState="false"  
                        PagerStyle-AlwaysVisible="true" AllowFilteringByColumn="true" FilterItemStyle-HorizontalAlign="Left"
                        <MasterTableView DataKeyNames="ReactionId" Width="100%" IsFilterItemExpanded="true" AllowFilteringByColumn="true"
                            <Columns> 
                                <telerik:GridBoundColumn DataField="ReactionId" HeaderText="Id" AllowFiltering="false" UniqueName="ReactionId" SortExpression="ReactionId"
                                    <HeaderStyle HorizontalAlign="Left" Width="20" /> 
                                    <ItemStyle HorizontalAlign="Left" Width="20" Wrap="false" Height="20px" /> 
                                </telerik:GridBoundColumn> 
                                <telerik:GridTemplateColumn UniqueName="VacancyName" DataField="VacancyName" InitializeTemplatesFirst="false" SortExpression="VacancyName" AllowFiltering="true"
                                    <HeaderTemplate> 
                                        <asp:LinkButton ID="btnVacancyName" Text="Vacaturetitel" ToolTip="Sorteren per vacaturetitel" CommandName="Sort" CommandArgument="VacancyName" runat="server"></asp:LinkButton> 
                                    </HeaderTemplate> 
                                    <HeaderStyle HorizontalAlign="Left" /> 
                                    <ItemTemplate> 
                                         <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
                                            <asp:LinkButton ID="btn_EditReaction" runat="server" CommandArgument='<%#Eval("ReactionId")%>' CssClass="lnk" CommandName="EditReaction" OnClick="Edit_OnClick" CausesValidation="false"><%#Eval("VacancyName")%></asp:LinkButton> 
                                         </telerik:RadCodeBlock> 
                                    </ItemTemplate> 
                                    <ItemStyle Width="100%" HorizontalAlign="left" /> 
                                </telerik:GridTemplateColumn> 
                                <telerik:GridBoundColumn DataField="StatusName" HeaderText="Status" UniqueName="StatusName" SortExpression="StatusName"
                                    <ItemStyle HorizontalAlign="Left" Wrap="false" /> 
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="ReactionDate" HeaderText="Reactiedatum" UniqueName="ReactionDate" DataType="System.DateTime" DataFormatString="{0:dd-MM-yyyy}" SortExpression="ReactionDate"
                                    <ItemStyle HorizontalAlign="Left" Wrap="false" /> 
                                </telerik:GridBoundColumn> 
                            </Columns> 
                        </MasterTableView> 
                        <PagerStyle Mode="NextPrevAndNumeric" NextPageText="Volgende pagina" PrevPageText="Vorige pagina" NextPagesToolTip="Volgende pagina" PrevPagesToolTip="Vorige pagina" PagerTextFormat="Pagina: {4}  Pagina {0} tot {3} op {5}"  />  
                        <GroupingSettings CaseSensitive="false" /> 
                        <FilterMenu EnableTheming="true" Skin="Office2007"
                            <collapseAnimation Duration="200" Type="OutQuint" /> 
                        </FilterMenu> 
                        <ClientSettings AllowDragToGroup="False" EnableRowHoverStyle="true"></ClientSettings> 
                    </telerik:RadGrid> 


and the filter code :

/// <summary> 
        /// reduce menu filter options 
        /// </summary> 
        /// <param name="sender">object</param> 
        /// <param name="e">EventArgs</param> 
        /// translation: 
        /// NoFilter = Geen filter 
        /// Contains = Bevat het woord 
        /// Equal to = Gelijk aan 
        /// StartsWith = Begint met 
        /// EndsWith = Eindigd met 
        protected void RadGrid_Init(object sender, EventArgs e) 
        { 
            GridFilterMenu menu = RadGrid1.FilterMenu; 
            int i = 0
            while (i < menu.Items.Count
            { 
                if (menu.Items[i].Text == "NoFilter") 
                { 
                    menu.Items[i].Text = "Geen filter"
                    i++; 
                } 
                else if (menu.Items[i].Text == "Contains") 
                { 
                    menu.Items[i].Text = "Bevat het woord"
                    i++; 
 
                } 
                else if (menu.Items[i].Text == "EqualTo") 
                { 
                    menu.Items[i].Text = "Gelijk aan"
                    i++; 
                } 
                else if (menu.Items[i].Text == "StartsWith") 
                { 
                    menu.Items[i].Text = "Begint met"
                    i++; 
                } 
                else if (menu.Items[i].Text == "EndsWith") 
                { 
                    menu.Items[i].Text = "Eindigd met"
                    i++; 
                } 
                else 
                { 
                    menu.Items.RemoveAt(i); 
                } 
            } 
        } 


Thanks for your help.

Edwin.



1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Apr 2009, 10:13 AM
Hi Edwin Blom,

When you apply the following DateTime format - dd/MM/yyyy the filter criteria will be retained on paging/sorting operation. Note, however, the OrderDate column with be filtered "separately" from the rest of the grid columns, meaning that:
    • the filters for the other columns in the grid will be cleared when you choose filter pattern for the OrderDate column
    • the OrderDate column filter will be cleared when you specify filter for some other column
For more details review the following help topic:
Filtering for DateTime bound column with DataFormatString different than mm/dd/yyyy

I hope this information helps.

Regards,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Hans van Rijnswoud
Top achievements
Rank 2
Answers by
Pavlina
Telerik team
Share this question
or