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

Grid filter contains not finding anything

13 Answers 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Max
Top achievements
Rank 1
Max asked on 06 Apr 2016, 04:37 PM
Hello, I have a grid column where items look like this: "Insulation - 02 - 1 - 15000". The problem is if for that column filter I put in a number and select contains it returns nothing.

13 Answers, 1 is accepted

Sort by
0
Roberto
Top achievements
Rank 1
answered on 06 Apr 2016, 05:27 PM

Your column is string? 

DataType="System.String"

Post your grid markup.

 

0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 06:09 PM

Here is the markup for the entire grid, the column I'm searching on is ActivityTypeID. Also the contains filter seems to be working ok if I put only letters in the search box, but numbers and letters like: "Insulation - 02" also gives nothing matched.

01.<telerik:RadGrid ID="ActivityTypeSkillGrid" runat="server" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"
02.    AllowAutomaticUpdates="True" AllowPaging="True" AutoGenerateColumns="False" GridLines="None"
03.    Skin="WebBlue" Width="822px" PageSize="20" Visible="false" OnItemCommand="Grid_ItemCommand"
04.    OnItemInserted="Grid_ItemInserted" OnItemDeleted="Grid_ItemDeleted" OnItemUpdated="Grid_ItemUpdated"
05.    AllowFilteringByColumn="true" OnItemDataBound="Grid_ItemDataBound" AllowSorting="true">
06.    <GroupingSettings CaseSensitive="false" />
07.    <ExportSettings>
08.        <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in"
09.            PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" />
10.    </ExportSettings>
11.    <PagerStyle Mode="NextPrevAndNumeric" />
12.    <MasterTableView DataKeyNames="ID" EditMode="InPlace" TableLayout="Fixed" Width="100%"
13.        CommandItemDisplay="Top">
14.        <RowIndicatorColumn Visible="False">
15.            <HeaderStyle Width="20px" />
16.        </RowIndicatorColumn>
17.        <ExpandCollapseColumn Resizable="False" Visible="False">
18.            <HeaderStyle Width="20px" />
19.        </ExpandCollapseColumn>
20.        <Columns>
21.            <telerik:GridEditCommandColumn>
22.                <HeaderStyle Width="80px" />
23.            </telerik:GridEditCommandColumn>
24.            <telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" DataField="ID" SortExpression="ID" Visible="false">
25.            </telerik:GridBoundColumn>
26.            <telerik:GridBoundColumn DataField="CompanyID" DataType="System.Guid" Visible="False"
27.                HeaderText="CompanyID" SortExpression="CompanyID" UniqueName="CompanyID">
28.            </telerik:GridBoundColumn>
29.            <telerik:GridDropDownColumn UniqueName="ProjectNo" HeaderText="Project No" DataField="ProjectNo"
30.                FilterImageUrl="images/Filter.gif" FilterControlWidth="100%" DataType="System.String"
31.                DataSourceID="ProjectNoLookupDS" EnableEmptyListItem="True" ListTextField="Code"
32.                ListValueField="Code">
33.                <HeaderStyle Width="150px" />
34.            </telerik:GridDropDownColumn>
35. 
36.            <telerik:GridDropDownColumn UniqueName="ActivityTypeID" HeaderText="Activity Type" DataField="ActivityTypeID"
37.                FilterImageUrl="images/Filter.gif" FilterControlWidth="100%" DataType="System.String"
38.                DataSourceID="ActivityTypeLookupDS" EnableEmptyListItem="True" ListTextField="ExtDescription"
39.                ListValueField="ID" ColumnEditorID="ActivityTypeIDColumnEditor" SortExpression="ActivityType">
40.                <HeaderStyle Width="490px" />
41.            </telerik:GridDropDownColumn>
42. 
43.            <telerik:GridBoundColumn UniqueName="ActivityTypeName" DataField="ActivityType" Display="false" ReadOnly="true">
44.            </telerik:GridBoundColumn>
45. 
46.            <telerik:GridDropDownColumn UniqueName="SkillID" HeaderText="Skill" DataField="SkillID"
47.                FilterImageUrl="images/Filter.gif" FilterControlWidth="100%" DataType="System.String"
48.                DataSourceID="SkillLookupDS" EnableEmptyListItem="True" ListTextField="Skill"
49.                ListValueField="ID" SortExpression="Skill">
50.                <HeaderStyle Width="100px" />
51.            </telerik:GridDropDownColumn>
52. 
53.            <telerik:GridBoundColumn UniqueName="SkillName" DataField="Skill" Display="false" ReadOnly="true">
54.            </telerik:GridBoundColumn>
55. 
56.        </Columns>
57.        <EditFormSettings>
58.            <EditColumn UniqueName="EditCommandColumn1">
59.            </EditColumn>
60.        </EditFormSettings>
61.    </MasterTableView>
62.</telerik:RadGrid>

0
Roberto
Top achievements
Rank 1
answered on 06 Apr 2016, 06:16 PM
0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 06:42 PM
Looking through the code here it seems to be following that example exactly.
0
Roberto
Top achievements
Rank 1
answered on 06 Apr 2016, 07:00 PM

Test with GridTemplateColumn. Add ActivityType to DataField to filter works and in EditItemTemplate you add one RadComboBox:

 

<telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Left" FilterControlWidth="100" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" DataField="ActivityType" DataType="System.String" HeaderText="ActivityType" SortExpression="ActivityType" UniqueName="ActivityType" >
    <ItemTemplate>
        <asp:Label ID="ActivityType" runat="server" Text='<%#Bind("ActivityType") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadComboBox ID="ActivityTypeID" runat="server" DataSourceID="ActivityTypeLookupDS" DataValueField="ID" DataTextField="ExtDescription" SelectedValue='<%#Bind("ActivityTypeID") %>'></telerik:RadComboBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 07:27 PM
This has an interesting problem. There are two columns Description and ExtDescription. ExtDescription is the one I want to show, but this makes Description the one that shows.
0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 07:28 PM
Decription and ExtDescription are columns in the database
0
Roberto
Top achievements
Rank 1
answered on 06 Apr 2016, 07:38 PM

Concatenate two columns on DataSource:

 

Select ID, Description + '' + Ext Description as Desc From YourTableName

In DataTextField from RadComboBox link Desc Field

0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 07:50 PM
I don't want them concatenated. This is showing Description as the text instead of ExtDescription, despite  DataTextField="ExtDescription"
0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 07:55 PM
Actually this is probably related to my problem. I think it has been filtering on the Description column instead of ExtDescription like it should be.
0
Roberto
Top achievements
Rank 1
answered on 06 Apr 2016, 08:08 PM
The DataField of the GridTemplateColumn is responsible for the filter. The DataTextField of the RadComboBox is only used to edit the data.
0
Max
Top achievements
Rank 1
answered on 06 Apr 2016, 08:54 PM
I mean in my original code.
0
Eyup
Telerik team
answered on 11 Apr 2016, 02:02 PM
Hi Max,

The grid can filter the items by the ExtDescription field only if it is present in the grid's datasource. To paraphrase Roberto's suggestion:
<telerik:GridTemplateColumn DataField="ExtDescription"
    FilterControlAltText="Filter ExtDescription column" HeaderText="ExtDescription"
    SortExpression="ExtDescription" UniqueName="ExtDescription">
    <ItemTemplate>
        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ExtDescription") %>'></asp:Label>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadComboBox ID="RadComboBoxActivity" runat="server"
            DataSourceID="ActivityTypeLookupDS" DataTextField="ExtDescription"
            DataValueField="ID" SelectedValue='<%# Bind("ActivityTypeID") %>'>
        </telerik:RadComboBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

Regards,
Eyup
Telerik
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Max
Top achievements
Rank 1
Answers by
Roberto
Top achievements
Rank 1
Max
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or