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

Filter a template column with values from multiple datafields

10 Answers 529 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 02 Aug 2013, 09:55 AM

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

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Aug 2013, 01:04 PM
Hi Andrew,

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
0
Tom Lynch
Top achievements
Rank 1
answered on 24 Jun 2014, 04:37 PM
But how do make the filter operate using the values of both FirstName and LastName?  Can you define it like, DataField="FirstName, LastName" or is it more complicated than that?  I'm currently using version 2010.2.929.20 of Telerik.Web.UI.dll.  I know I ought to upgrade, but that's not possible at the moment.
0
Princy
Top achievements
Rank 2
answered on 25 Jun 2014, 07:09 AM
Hi Tom Lynch,

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
0
Vasssek
Top achievements
Rank 1
answered on 22 Nov 2015, 01:22 PM

Hello,

Is it still impossible to filter on two or more datafields in one template column ?

Than you

Vasssek

0
Eyup
Telerik team
answered on 25 Nov 2015, 08:34 AM
Hi 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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Vasssek
Top achievements
Rank 1
answered on 30 Nov 2015, 07:25 PM

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

0
Madel
Top achievements
Rank 1
answered on 20 Apr 2020, 09:15 AM

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

 

0
Eyup
Telerik team
answered on 23 Apr 2020, 04:25 AM

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

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Madel
Top achievements
Rank 1
answered on 26 May 2020, 11:19 AM

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.

 

 

0
Eyup
Telerik team
answered on 29 May 2020, 07:42 AM

Hello ,

 

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

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Tom Lynch
Top achievements
Rank 1
Vasssek
Top achievements
Rank 1
Eyup
Telerik team
Madel
Top achievements
Rank 1
Share this question
or