Filter a template column with values from multiple datafields

11 posts, 0 answers
  1. Andrew
    Andrew avatar
    1 posts
    Member since:
    Aug 2013

    Posted 02 Aug 2013 Link to this post

    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>
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2013 Link to this post

    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
  3. Tom Lynch
    Tom Lynch avatar
    78 posts
    Member since:
    Mar 2005

    Posted 24 Jun 2014 in reply to Princy Link to this post

    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.
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jun 2014 in reply to Tom Lynch Link to this post

    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
  5. Vasssek
    Vasssek avatar
    190 posts
    Member since:
    Aug 2010

    Posted 22 Nov 2015 in reply to Princy Link to this post

    Hello,

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

    Than you

    Vasssek

  6. Eyup
    Admin
    Eyup avatar
    3953 posts

    Posted 25 Nov 2015 Link to this post

    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
  7. Vasssek
    Vasssek avatar
    190 posts
    Member since:
    Aug 2010

    Posted 30 Nov 2015 in reply to Eyup Link to this post

    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

  8. Madel
    Madel avatar
    2 posts
    Member since:
    Jul 2016

    Posted 20 Apr in reply to Eyup Link to this post

    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

     

  9. Eyup
    Admin
    Eyup avatar
    3953 posts

    Posted 22 Apr Link to this post

    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.
  10. Madel
    Madel avatar
    2 posts
    Member since:
    Jul 2016

    Posted 26 May in reply to Eyup Link to this post

    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.

     

     

  11. Eyup
    Admin
    Eyup avatar
    3953 posts

    Posted 29 May Link to this post

    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.
Back to Top