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

Filter is not working in grid template column

3 Answers 1031 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Bhuvaneshwari
Top achievements
Rank 1
Bhuvaneshwari asked on 19 Dec 2014, 09:27 AM
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

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 24 Dec 2014, 08:12 AM
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.

 
0
Bhuvaneshwari
Top achievements
Rank 1
answered on 30 Dec 2014, 07:07 AM
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.
0
Konstantin Dikov
Telerik team
answered on 30 Dec 2014, 07:17 AM
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.

 
Tags
Filter
Asked by
Bhuvaneshwari
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Bhuvaneshwari
Top achievements
Rank 1
Share this question
or