Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Grid > Filtering boolean values with images in Filtering Item

Filtering boolean values with images in Filtering Item

Feed from this thread
  • Posted on Sep 13, 2007 (permalink)

    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".

  • Posted on Feb 23, 2008 (permalink)

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

Back to Top

Skip Navigation LinksHome / Community & Support / Code Library / ASP.NET AJAX > Grid > Filtering boolean values with images in Filtering Item