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

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

6 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DonKitchen
Top achievements
Rank 1
DonKitchen asked on 04 Nov 2008, 07:19 PM
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?

6 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 04 Nov 2008, 09:17 PM
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. :) 
0
DonKitchen
Top achievements
Rank 1
answered on 04 Nov 2008, 11:31 PM
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> 
 

0
DonKitchen
Top achievements
Rank 1
answered on 05 Nov 2008, 02:10 PM
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...

<telerik:RadGrid ID="FranchiseListRadGrid" runat="server" SkinID="RadGridWithAdd" 
                AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" DataSourceID="FranchiseListDataSource" 
                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: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="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> 
                    </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> 

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?
0
DonKitchen
Top achievements
Rank 1
answered on 05 Nov 2008, 02:31 PM
I fixed it.  There was something goofed up in the view after all.

Thanks!
0
Mubarak
Top achievements
Rank 1
answered on 13 Mar 2012, 11:17 AM
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.
0
Richard
Top achievements
Rank 1
answered on 15 Mar 2012, 03:26 PM
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!
Tags
Grid
Asked by
DonKitchen
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
DonKitchen
Top achievements
Rank 1
Mubarak
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or