implement custom filtering

5 posts, 0 answers
  1. newbie
    newbie avatar
    355 posts
    Member since:
    Feb 2008

    Posted 06 Mar 2009 Link to this post

    I want to implement custom filtering on some of the columns in the grid.

    I want to display filtering options based on a databse field like Status = {active,Inactive,Pending,All}
    and display records from the database accordingly.

    How can I implement this functionality?

    Is it also possible to display a small button in the header column and on click of that button I pop-up a list with all the options?
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 09 Mar 2009 Link to this post

    Hi,

    A suggestion would be to use  a dropdownlist  to list your options and to filter the grid based on them .You can use the filter template to add  the  dropdownlist  . Check out the link below to know more on how to add a  filter template :

    http://www.telerik.com/help/aspnet-ajax/radgrid-filter-template.html

    You can add a control to the header either bu suing a GridTemplateColumn and placing a control to popup a window or add the control dynamically in the ItemCreated event:

      protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridHeaderItem) 
            { 
                GridHeaderItem headerItem = (GridHeaderItem)e.Item; 
                LinkButton popupLink = new LinkButton(); 
                popupLink.ID = "LinkButton1"
                popupLink.Text = "Click me"
                editLink.Attributes["onclick"] = String.Format("return ShowPopup();"); 
                headerItem["CustomerID"].Controls.Add(popupLink); 
            } 
        } 


    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 25 Feb 2010 Link to this post

    Hey Princy,

    I followed the example you gave and my custom filter works (I am using an objectdatasource), but with 3 issues:

    1.  When the grid rebinds, the RadComboBox display returns to index 0 - it needs to remain on the index the user selected, so if the user selected "pantyhose," the combobox remains at "pantyhose" and does not return to "whips and chains"

    2.  The example does not give a way out of the filter - once in, you are stuck.  How can I get a "no filter" option into the combobox?

    3.  The note at the bottom of the example ( http://www.telerik.com/help/aspnet-ajax/radgrid-filter-template.html ) surprises those who do not read the release notes (does anybody???) that LINQ syntax is the default (for .NET 3.5) for interpretting the syntax of the embedded SELECT, etc., statements in the presentation tier.  I don't understand this at all - how LINQ can be interpretting a database call from data access object.  I am not whining; I just don't understand it.  I will complain about the lack of references to how RadGrid can now use LINQ, especially LINQ2DataSets and LINQ2XML since most of the civilized world uses Oracle and both M$ and Oracle are in a pissing contest over this issue.

    Finally, I can't stand embedding busness rules in the presentation layer!!!  How do you access a Rad child control, like the combobox buried in a BoundGridColumn buried in a RadGrid from the server (code-behind)?  I have found not a single example or tutorial on this site that explains this.  That is not to say it doesn't exist, but it sure must be hard to find.  I really do not understand why you guys put your business logic in the web page.  Well....I do have some thoughts on that, but they are not nice.

    Cheers!
    Mark
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Feb 2010 Link to this post

    Hi,

    Please  have a look at the forum link where a similar issue has been discussed regarding a RadComboBox in FilterTemplate.


    Thanks,
    Princy
  6. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 26 Feb 2010 Link to this post

    Thanks, Princy!  Exactly what I needed!

    Cheers!
    Mark
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017