Filtering with Radgrid (contains works great, starts with does not)

7 posts, 0 answers
  1. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 04 Nov 2008 Link to this post

    Is there anything special that needs to be done behind the scenes or with a datasource in order to get the "Starts With" filtering working?  I can use the Contains fine with no problems, but when I try "Starts With" and "O" (upper or lower case) it just won't find the results.

    Am I missing something simple here?
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 04 Nov 2008 Link to this post

    Hey Don,

    Would you be able to post a copy of your code here for the grid?  I have a RadGrid running on our intranet right now that has filtering for some of the employee reports, and when I filter with Starts With I am not getting any problems, tried a variety of letters including O.

    Also, how are you populating the grid?  Wondering if there might be something getting pulled up in the data that sticks a character (space maybe?) before the data.  I know that screws me up in Excel all the time. :) 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 04 Nov 2008 Link to this post

    There are definitely no spaces in the data I'm bringing back.  Here's my grid...

           <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"
                <telerik:RadGrid ID="FranchiseListRadGrid" runat="server" SkinID="RadGridWithAdd" 
                    AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="FranchiseListDataSource" 
                    ShowStatusBar="true" ShowFooter="true" Width="700px" ActiveItemStyle-BackColor="yellow" 
                    EnableLinqExpressions="false"
                    <GroupingSettings CaseSensitive="false" /> 
                    <ClientSettings> 
                        <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
                    </ClientSettings> 
                    <MasterTableView DataSourceID="FranchiseListDataSource" CommandItemDisplay="top"
                        <Columns> 
                            <telerik:GridHyperLinkColumn AllowFiltering="False" DataNavigateUrlFields="FranchiseId" 
                                DataNavigateUrlFormatString="FranchiseEdit.aspx?FranchiseId={0}" Groupable="False" 
                                Reorderable="False" Text="View" UniqueName="ViewColumn"
                            </telerik:GridHyperLinkColumn> 
                            <telerik:GridBoundColumn AllowFiltering="False" DataField="FranchiseId" DataType="System.Int32" 
                                HeaderText="ID" SortExpression="FranchiseId" UniqueName="FranchiseId" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="50px" ItemStyle-HorizontalAlign="center"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="true" DataField="FranchiseName" HeaderText="Name" 
                                SortExpression="FranchiseName" UniqueName="FranchiseName" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left" 
                                CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="false" DataField="State" HeaderText="State" 
                                SortExpression="State" UniqueName="State" HeaderStyle-Width="50px" HeaderStyle-HorizontalAlign="Center" 
                                ItemStyle-HorizontalAlign="center"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="False" DataField="OwnerFirstName" HeaderText="Owner<br>First Name" 
                                AllowSorting="false" UniqueName="OwnerFirstName" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="true" DataField="OwnerLastName" HeaderText="Owner<br>Last Name" 
                                SortExpression="OwnerLastName" UniqueName="OwnerLastName" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left" CurrentFilterFunction="Contains" 
                                AutoPostBackOnFilter="true"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="False" DataField="OpsRepFirstName" HeaderText="Ops Rep<br>First Name" 
                                AllowSorting="false" UniqueName="OpsRepFirstName" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left"
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn AllowFiltering="true" DataField="OpsRepLastName" HeaderText="Ops Rep<br>Last Name" 
                                SortExpression="OpsRepLastName" UniqueName="OpsRepLastName" HeaderStyle-HorizontalAlign="Center" 
                                HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left" 
                                CurrentFilterFunction="contains" AutoPostBackOnFilter="true"
                            </telerik:GridBoundColumn> 
                        </Columns> 
                        <CommandItemTemplate> 
                            <div style="text-align: left;"
                                <table style="text-align: left;"
                                    <tr> 
                                        <td valign="middle"
                                            <telerik:RadComboBox runat="server" ID="FranchiseComboBox" AutoPostBack="true" AppendDataBoundItems="True" 
                                                DataSourceID="FranchiseDataSource" DataValueField="FranchiseId" DataTextField="FranchiseName" 
                                                Height="150px" OnSelectedIndexChanged="FranchiseComboBox_SelectedIndexChanged"
                                                <Items> 
                                                    <telerik:RadComboBoxItem Value="" Text="Select a franchise" /> 
                                                </Items> 
                                            </telerik:RadComboBox> 
                                        </td> 
                                        <td valign="middle"
                                            <asp:Button ID="AddFranchiseButton" runat="Server" Text="Add Franchise" Style="padding-top: 0px; 
                                                padding-bottom: 0px;" SkinID="Default" OnClick="AddFranchiseButton_Click" />&nbsp; 
                                        </td> 
                                    </tr> 
                                </table> 
                            </div> 
                        </CommandItemTemplate> 
                        <NoRecordsTemplate> 
                            No franchises exist 
                        </NoRecordsTemplate> 
                        <FilterItemStyle /> 
                    </MasterTableView> 
                </telerik:RadGrid> 
            </telerik:RadAjaxPanel> 
     

  5. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 05 Nov 2008 Link to this post

    What else is weird is that for the two columns I allow filtering for, one of them works fine, the other it can't handle "Starts With".  Here are the two columns...

    1 <telerik:RadGrid ID="FranchiseListRadGrid" runat="server" SkinID="RadGridWithAdd" 
    2                 AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="FranchiseListDataSource" 
    3                 ShowFooter="true" Width="700px" ActiveItemStyle-BackColor="yellow" 
    4                 EnableLinqExpressions="false"
    5                 <GroupingSettings CaseSensitive="false" /> 
    6                 <ClientSettings> 
    7                     <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
    8                 </ClientSettings>                 
    9                 <MasterTableView DataSourceID="FranchiseListDataSource" CommandItemDisplay="top"
    10                     <Columns> 
    11                         <telerik:GridBoundColumn AllowFiltering="true" DataField="FranchiseName" HeaderText="Name" 
    12                             SortExpression="FranchiseName" UniqueName="FranchiseName" HeaderStyle-HorizontalAlign="Center" 
    13                             HeaderStyle-VerticalAlign="middle" HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left" 
    14                             CurrentFilterFunction="Contains" AutoPostBackOnFilter="true"
    15                         </telerik:GridBoundColumn> 
    16                         <telerik:GridBoundColumn AllowFiltering="true" DataField="OwnerLastName" HeaderText="Owner<br>Last Name" 
    17                             SortExpression="OwnerLastName" UniqueName="OwnerLastName" HeaderStyle-HorizontalAlign="Center" 
    18                             HeaderStyle-Width="100px" ItemStyle-HorizontalAlign="left" CurrentFilterFunction="Contains" 
    19                             AutoPostBackOnFilter="true"
    20                         </telerik:GridBoundColumn> 
    21                     </Columns> 
    22                     <CommandItemTemplate> 
    23                         <div style="text-align: left;"
    24                             <table style="text-align: left;"
    25                                 <tr> 
    26                                     <td valign="middle"
    27                                         <telerik:RadComboBox runat="server" ID="FranchiseComboBox" AutoPostBack="true" AppendDataBoundItems="True" 
    28                                             DataSourceID="FranchiseDataSource" DataValueField="FranchiseId" DataTextField="FranchiseName" 
    29                                             Height="150px" OnSelectedIndexChanged="FranchiseComboBox_SelectedIndexChanged"
    30                                             <Items> 
    31                                                 <telerik:RadComboBoxItem Value="" Text="Select a franchise" /> 
    32                                             </Items> 
    33                                         </telerik:RadComboBox> 
    34                                     </td> 
    35                                     <td valign="middle"
    36                                         <asp:Button ID="AddFranchiseButton" runat="Server" Text="Add Franchise" Style="padding-top: 0px; 
    37                                             padding-bottom: 0px;" SkinID="Default" OnClick="AddFranchiseButton_Click" />&nbsp; 
    38                                     </td> 
    39                                 </tr> 
    40                             </table> 
    41                         </div> 
    42                     </CommandItemTemplate> 
    43                     <NoRecordsTemplate> 
    44                         No franchises exist 
    45                     </NoRecordsTemplate> 
    46                     <FilterItemStyle /> 
    47                 </MasterTableView> 
    48             </telerik:RadGrid> 

    Any ideas why one, Owner Last Name, can't handle the "Starts With" filtering and the other, FranchiseName, can?

    The datasource that the grid is bound to is based on a view.  The only difference between the two fields in the view is that the Owner Last Name uses an alias in the field name.

    Could this make a difference?
  6. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 05 Nov 2008 Link to this post

    I fixed it.  There was something goofed up in the view after all.

    Thanks!
  7. Mubarak
    Mubarak avatar
    1 posts
    Member since:
    Mar 2012

    Posted 13 Mar 2012 Link to this post

    Hi Donkitchen,

               How you fixed that "StartWith" filter not working problem, Because same Problem was occured me.Contains filter is Working Fine but startsWith and EndsWith not Woking.Kindly Guide me as soon as possible.
  8. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 15 Mar 2012 Link to this post

    Mubarak:

    This type of behavior could be caused when the CurrentFilterFunction property for your column(s) is explicitly set in the markup. Is this your case?

    Take a look at this thread for some insights: RadGrid CurrentFilterFunction="StartsWith" not working

    Hope this helps!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017