Filtering boolean values with images in Filtering Item

Thread is closed for posting
2 posts, 0 answers
  1. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 13 Sep 2007 Link to this post

    Requirements

    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    4.6.2 and later


    2008.1.415 and later
    .NET version

    2.0 and later
    Visual Studio version

    2005 and later
    programming language

    C#
    Browser support

    all supported by RadGrid for ASP .NET


    all browsers supported by RadControls for ASP .NET AJAX


     
    PROJECT DESCRIPTION
    This project shows how to extend GridTemplateColumn, so that it can be used to filter boolean values with images in the filtering item. Here are the basic steps:
    • Extend GridTemplateColumn, provide the image buttons which will be used for filtering.
      protected override void SetupFilterControls(TableCell cell) 
          ImageButton but = new ImageButton(); 
          but.ID = "TrueButton" + this.UniqueName; 
          but.ImageUrl = "~/true.gif"
          but.Click += new ImageClickEventHandler(butTrue_Click); 
          but.ToolTip = "True"
          cell.Controls.Add(but); 
          ........ 
    • Use a hidden field to store CurrentFilterValue
    • Handle each ImageButton Click event handler to set CurrentFilterFunction and CurrentFilteValue:
      void butTrue_Click(object sender, ImageClickEventArgs e) 
          { 
              this.CurrentFilterFunction = GridKnownFunction.EqualTo; 
              this.CurrentFilterValue = "true"
              Pair arg = new Pair(GridKnownFunction.EqualTo.ToString(), this.UniqueName); 
              SetCurrentFilterValueToControl(((sender as Control).Parent as TableCell)); 
       
              ((sender as Control).NamingContainer as GridFilteringItem).FireCommandEvent(RadGrid.FilterCommandName, arg); 
          } 
    This would not interfere with sorting functionality. A grouping expression is required for grouping, as shown in the attached project.

    Note: For 3.5/4.0 projects Grid.EnableLinqExpressions should be set to "false".
  2. Telerik Admin
    Telerik Admin avatar
    1679 posts
    Member since:
    Oct 2004

    Posted 23 Feb 2008 Link to this post

    An updated version of the project, using RadControls "Prometheus" is attached to the initial post. No major changes in the code.
Back to Top