Skip to content

Highlight row based on conditions

New Discussion
hsn rhn
hsn rhn asked on Oct 12, 2017 8:40 AM

Hi

I have a grid which I want to highlight rows based on conditions. for example, set back color of rows which have column x greater than 2 into red.   can I use ColumnFilters in data band for it. 

thanks in advance

Sign In to post a reply

Replies

  • 0
    Mike Saltzman
    Mike Saltzman answered on Oct 10, 2017 2:35 PM

    Hi, 

    Yes, you can – assuming you only want to apply a single appearance to the cells based on a single set of conditions. 

    In other words, if you want to filter a column so that it detects values greater than 0 and apply an appearance to cells that do not meet that condition, you can do that. But if you want to detect multiple criteria and apply multiple appearances like for example: 

    <0 = red

    0 – 100 = Yellow

    >100 = Green

    Then you cannot do that using ColumnFilters. Filtering is a binary condition. A row is either filtered out or it's not, so you can only use to apply a single appearance. 

    If you need more than one appearance, the best way to do that is to use the InitializeRow event. In fact, the InitializeRow event is probably better, anyway, because if you use ColumnFilters to apply the appearance, then that means your users cannot use the grid's filtering functionality for anything else. 

    • 0
      hsn rhn
      hsn rhn answered on Oct 11, 2017 12:06 PM

      Thanks for reply. But as far as I know ColumnFilters just filter the rows based on conditions; which means it doesn't display those rows not meeting the criteria. but I want to change appearance of rows not just stop displaying them. how can I do that with ColumnFilters.

      • 0
        Mike Saltzman
        Mike Saltzman answered on Oct 11, 2017 2:31 PM

        Hi, 

        Okay, if that's what you want to do, then you need to set the RowFilterAction property and then define the FilteredInRowAppearance, FilteredOutRowAppearance, FilteredInCellAppearance, and/or FilteredOutCellAppearance that you want. 

        
        

        private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
        {
        var layout = e.Layout;
        var band = layout.Bands[0];
        var ov = layout.Override;

        ov.AllowRowFiltering = DefaultableBoolean.True;
        ov.FilterUIType = FilterUIType.FilterRow;
        ov.RowFilterAction = RowFilterAction.AppearancesOnly;
        ov.FilteredInRowAppearance.BackColor = Color.Blue;
        ov.FilteredInRowAppearance.ForeColor = Color.White;
        ov.FilteredOutRowAppearance.BackColor = Color.Yellow;
        ov.FilteredOutRowAppearance.ForeColor = Color.Black;
        }

      • 0
        hsn rhn
        hsn rhn answered on Oct 12, 2017 8:40 AM

        Thanks for reply. exactly what I need.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
hsn rhn
Favorites
0
Replies
4
Created On
Oct 12, 2017
Last Post
8 years, 6 months ago

Suggested Discussions

Tags

Created by

Created on

Oct 12, 2017 8:40 AM

Last activity on

Oct 12, 2017 8:40 AM