radgrid : custom filter menu by column in GridTemplateColumn

2 posts, 0 answers
  1. Vincent
    Vincent avatar
    13 posts
    Member since:
    Feb 2016

    Posted 03 Aug 2018 Link to this post

    Hi from France !

    I need to make specific filter by column. columns are itemTemplate. in my original projet i've got many data in different columns/template like this :


    <telerik:GridTemplateColumn UniqueName="situationCertif" ItemStyle-CssClass="situationBloc">
                                               <asp:Label ID="libFacture" runat="server" Text='<%# String.Format("Facture n° {0}", Eval("LibFacture"))%>'></asp:Label>
                                               <asp:Label ID="lMontantHT" runat="server" Text='<%# String.Format("Montant HT : {0:C2}", Eval("MontantHT"))%>'></asp:Label>
                                               <asp:Label ID="lMontantTTC" runat="server" Text='<%# String.Format("Montant TTC : {0:C2}", Eval("MontantTTC"))%>'></asp:Label>
                                               <asp:Label ID="lEtat" runat="server" Text='<%# String.Format("Etat :  {0}", Eval("Etat.LongString"))%>'></asp:Label>
                                                   Payer à :
                                                   <asp:Label ID="lTiersPayeur" runat="server" CssClass="tiers" Text='<%# String.Format("{0}", Eval("NomTiersPayeur"))%>'></asp:Label>


    I've maked a sample to search how to made this (see Grid.png)

    i've got a class "TestData" binded to template columns :

    Public Class TestData
        Property Nom As String
        Property Prenom As String
        Property age As Integer
        Property statut As String
        Property Infos As String
        Public Sub New(nom As String, prenom As String, age As Byte, statut As String, infos As String)
            Me.Nom = nom
            Me.Prenom = prenom
            Me.age = age
            Me.statut = statut
            Me.Infos = infos
        End Sub
    End Class
    Private Sub SetGridData()
        Dim list As New List(Of TestData) From
        New TestData("Albert", "Bebert", 28, "Directeur", "ux texte standard de l'imprimerie depuis les années 1500, quand un imprimeur anonyme assembla ensemble des morceaux de texte pour réaliser un livre spécimen"),
        New TestData("Bilal", "Ournis", 25, "Ingénieur", ""),
        New TestData("Jerôme", "Nimo", 35, "Commercial", " sans que son contenu n'en soit modifié. Il a été popularisé dans les années 1960 grâce à la "),
        New TestData("Elvira", "Pas", 50, "Commercial", ""),
        New TestData("Sylvestre", "Saint", 47, "Commercial", "s suites logicielles de mise en page ou éditeurs de sites Web ont fait du Lorem Ipsum leur faux texte par défaut, et une recherche pour 'Lorem Ipsum' vous cond")
        RadGrid1.DataSource = list
    End Sub


    <telerik:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="true" AutoGenerateColumns="false" OnInit="RadGrid1_Init" OnItemCommand="RadGrid1_ItemCommand">                  
                    <telerik:GridTemplateColumn FilterListOptions="VaryByDataTypeAllowCustom" DataField="demo" UniqueName="demo">
                        <h1><%# Eval("Nom") %></h1>
                        <h3><%# Eval("Prenom") %></h3>
                        <i><%# Eval("Age") %></i>
                     <telerik:GridTemplateColumn FilterListOptions="VaryByDataTypeAllowCustom" DataField="infos" UniqueName="infos">
                        <p><b><%# Eval("Statut") %></b></p>
                        <p><%# Eval("Infos") %></p>


    example : 

    First column i need to search in "Nom" or "Prenom" or "Age" properties (contain mode)

    Second column i need to search in "Statut" or "Infos" properties (contain mode)

    How to define a filter menu by column ?

    Thanks for your help, and excuse me for my bad english.

  2. Attila Antal
    Attila Antal avatar
    609 posts

    Posted 08 Aug 2018 Link to this post

    Hi Vincent,

    The described filtering mechanism is not supported by default. What you can do is cancel the original event, and fire a filtering command that will be applied for another column. (see attached RadGridFilterDifferentColumn.zip). In addition to that, you can find several more examples attached that you can check out for reference to get a better understanding on custom filtering.

    Here are some more articles that can help in this topic: Custom Option for FilteringReduce the Filter Menu OptionsCustom Filter Options with HandlingOperate with the FilterExpression Manually.

    It is important, when using more complex operations with RadGrid, we highly recommend using an advanced databinding method like Declarative DataSource or using the Advanced Data-binding (Using NeedDataSource Event)

    Kind Regards,
    Attila Antal
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top