Grid filter contains not finding anything

14 posts, 0 answers
  1. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr Link to this post

    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.
  2. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 06 Apr in reply to Max Link to this post

    Your column is string? 

    DataType="System.String"

    Post your grid markup.

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Roberto Link to this post

    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>

  5. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 06 Apr in reply to Max Link to this post

  6. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Roberto Link to this post

    Looking through the code here it seems to be following that example exactly.
  7. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 06 Apr in reply to Max Link to this post

    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>

  8. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Roberto Link to this post

    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.
  9. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Max Link to this post

    Decription and ExtDescription are columns in the database
  10. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 06 Apr in reply to Max Link to this post

    Concatenate two columns on DataSource:

     

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

    In DataTextField from RadComboBox link Desc Field

  11. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Roberto Link to this post

    I don't want them concatenated. This is showing Description as the text instead of ExtDescription, despite  DataTextField="ExtDescription"
  12. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr in reply to Max Link to this post

    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.
  13. Roberto
    Roberto avatar
    13 posts
    Member since:
    Mar 2011

    Posted 06 Apr in reply to Max Link to this post

    The DataField of the GridTemplateColumn is responsible for the filter. The DataTextField of the RadComboBox is only used to edit the data.
  14. Max
    Max avatar
    18 posts
    Member since:
    Apr 2016

    Posted 06 Apr Link to this post

    I mean in my original code.
  15. Eyup
    Admin
    Eyup avatar
    3007 posts

    Posted 11 Apr Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017