May 20, 2011

Just The Code: Two Telerik RadGrid Extension Methods


Last night I found myself needing to add the same functionality to several RadGrids in my application. Rather than copy & paste, I decided to be kind to my future self and thus created two extension methods:
  1. SetDefaultSort -- This method sets a default sort on a RadGrid - for instance, to sort by a datetime column when the page loads.
  2. ClearFilters -- For a RadGrid that has filters implemented, this method allows you to consistently clear filters - for instance, when a user clicks a "Refresh" or "Clear Filters" button.

    Here is the code:



Want to learn more about extension methods? Check out Professional C# 2008 (Wrox Professional Guides), it's how I learned all about them.

Happy Coding!


(P.S.: Want to give me some feedback? You can always leave comments here, email me directly (brian at brian-driscoll.com), or catch me on Twitter (I'm @driscollwebdev)
Post a Comment