Filter is not working in grid template column

4 posts, 0 answers
  1. Bhuvaneshwari
    Bhuvaneshwari avatar
    7 posts
    Member since:
    Nov 2014

    Posted 19 Dec 2014 Link to this post

    I am using the below code for displaying crew qualification in a radgrid.

    <telerik:GridTemplateColumn DataField="CrewQualification"
    FilterControlAltText="Filter CrewQualification column" HeaderText="Crew Details"
    UniqueName="CrewQualification" FilterControlWidth="40px">
    <ItemTemplate>
    <asp:HyperLink ID="CrewInfoLink" Font-Underline="true" runat="server" Text="Edit" CssClass="mousechange"></asp:HyperLink>
    <asp:Label ID ="CrewLabel" runat="server" Text="Edit" ></asp:Label>
    </ItemTemplate>
    <HeaderStyle Width="80px" />
    </telerik:GridTemplateColumn>

    But the filter in that column is not working despite of adding 'AllowFilteringByColumn,AllowFiltering,AutoPostBackOnFilter' and also 'Datatype' properties to this grid template column.Please help me in this
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 24 Dec 2014 Link to this post

    Hi Bhuvaneshwari,

    Your GridTemplateColumn settings are correct and if you set the AllowFilteringByColumn property of the grid to true you will be able to filter by the "CreaQualification" data field for that column. Please keep in mind that the filtering is performed on the data field and not on the displayed values in the cells.

    Below is a simple example with your GridTemplateColumn that works correctly on my end:
    <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" AllowFilteringByColumn="true" AllowPaging="true" Width="400px">
        <MasterTableView CommandItemDisplay="Top" EditMode="Batch" AutoGenerateColumns="false">
            <Columns>
                <telerik:GridBoundColumn DataField="ID"></telerik:GridBoundColumn>
                <telerik:GridTemplateColumn DataField="CrewQualification"
                    FilterControlAltText="Filter CrewQualification column" HeaderText="Crew Details"
                    UniqueName="CrewQualification" FilterControlWidth="40px">
                    <ItemTemplate>
                        <asp:HyperLink ID="CrewInfoLink" Font-Underline="true" runat="server" Text="Edit" CssClass="mousechange"></asp:HyperLink>
                        <asp:Label ID="CrewLabel" runat="server" Text="Edit"></asp:Label>
                    </ItemTemplate>
                    <HeaderStyle Width="80px" />
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

    And the dummy data:
    protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID", typeof(int));
        table.Columns.Add("CrewQualification", typeof(string));
        for (int i = 0; i < 555; i++)
        {
            table.Rows.Add(i, "CrewQualification" + i);
        }
     
        (sender as RadGrid).DataSource = table;
    }

    You can test the above by entering "2" in the filter and choosing the "Contains" filter function.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bhuvaneshwari
    Bhuvaneshwari avatar
    7 posts
    Member since:
    Nov 2014

    Posted 30 Dec 2014 in reply to Konstantin Dikov Link to this post

    Thanks Konstantin.
    PFA the screenshot where the grid contains the column(last column)  "CrewDetails" where i have to filter the values. In this column the values will be ,
    1.Details - Hyperlink
    2.No Crew - Label text value

    Please find the last column in the screenshot.
    Please note we have already used 'AllowFilterColumn=True' as you suggessted but it is not working.Please help me in this.
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 30 Dec 2014 Link to this post

    Hi Bhuvaneshwari,

    The filtering in RadGrid works on the underlying data and not on the displayed values in the column, so in your scenario, since the DataField property is set to CrewQualification, you will be filtering on those values.

    RadGrid does not provide a way for filtering on the displayed text, so the only thing that I could suggest is that you use custom filtering:
    Hope this helps.


    Best Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top