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

implement custom filtering

4 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 06 Mar 2009, 11:57 PM
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?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2009, 09:15 AM
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
0
Mark Galbreath
Top achievements
Rank 2
answered on 25 Feb 2010, 11:39 PM
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
0
Princy
Top achievements
Rank 2
answered on 26 Feb 2010, 09:19 AM
Hi,

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


Thanks,
Princy
0
Mark Galbreath
Top achievements
Rank 2
answered on 26 Feb 2010, 12:53 PM
Thanks, Princy!  Exactly what I needed!

Cheers!
Mark
Tags
Grid
Asked by
newbie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mark Galbreath
Top achievements
Rank 2
Share this question
or