I have a grid with a template column that contains values from two datafields.
How do I get the filtering to work on this column?
<
telerik:GridTemplateColumn
UniqueName
=
"Name"
HeaderText
=
"Name"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblFirstName"
runat
=
"server"
Text='<%# Eval("FirstName") %>'></
asp:Label
>
<
asp:Label
ID
=
"lblLastName"
runat
=
"server"
Text='<%# Eval("LastName") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
10 Answers, 1 is accepted
For a GridTemplateColumn,we have a property AllowFiltering,this has to be true,and a DataField property is required to filter the items for that column.If you want to filter by FirstName,give DataField="FirstName" else DataField="LastName".
Hope this helps.
Thanks,
Princy
I'm afraid currently RadGrid doesn't support passing multiple DataFields for filtering. You can have only either the filter to be done using FirstName or LastName according to the DataField set.
Thanks,
Princy
Hello,
Is it still impossible to filter on two or more datafields in one template column ?
Than you
Vasssek
Yes, this depends on the DataField property of the column, which can be set to only to a single database. Nevertheless, you can use a custom solution to create a new type of column as demonstrated in the attached web site sample and handle its filter expression manually.
Regards,
Eyup
Telerik
Hello,
thank you for your example. I solved my issue on SQL side, but I really appreciate it because of interesting custom databound column class. Maybe, I wil use something like this in my next project :-).
Vasssek
Hello Eyup,
Could you please explain what the datafield would be when filtering on the content for GridTemplatecolumn that contains multiple datafields using the custom solution
Thanks,
Madel
Hi Madel,
For filtering it really does not matter since you are using custom filtering logic to achieve this. Since the column supports only 1 DataField at a time, you can set it to be the one which you prefer the Sorting to happen for example.
Regards,
Eyup
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hello Eyup,
The sample code you have provided (RadGridGilterApostropheInsensitive.zip) filters on a single datafield property. Could you please provide a sample code for filtering a grid template column wihch has a combination of multiple datafield properties as in the question asked above.
Hello Madel,
In this case you can manipulate the FilterExpression of the MasterTableView and join the filter clause with "OR" statements instead of "AND" as demonstrated in the attached sample.
Regards,
Eyup
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.