Ticket T261219
Visible to All Users

how to apply conditional formatting to multiple columns

created 10 years ago

Our users really like the conditional formatting option, but some of your grids have many columns and we would like a way for our users to set the same conditional formatting on multiple columns at once. We were going to create a custom tool in order to accomplish this, but I wanted to make sure it wasn't already available.

If it is not available is there a way to utilize your menu options outside the column header context menu? If possible we would also like to use the conditional formatting icons to show what is set on a group of columns.

Thanks,
Doug

Show previous comments (15)

    The logic is pretty embedded in our application and I tried to create a sample project but so far haven't been able to reproduce the issue in it. One thing I did notice is that for the view that works the column I am using to create the menu items for has a FieldType of Int32 and in the view that doesn't work the column show a FieldType of object. In both views I am using the FieldName property to bind the data and in both cases the bound data type is an int. I am confused why one view would get the type correctly and not the other.

      I think I got this issue figured out. I was building the menu too soon, before the grid knew about its data and could determine what the column types were.

      Kirill (DevExpress Support) 10 years ago

        I'm happy to hear that you've resolved the issue.

        Answers approved by DevExpress Support

        created 10 years ago (modified 10 years ago)

        Hello,
        Our Conditional Formatting doesn't support applying rules for several columns at once. In general, the only way to accomplish this task is to duplicate FormatConditions for each column manually.
        If you want to apply an icon to a certain cell when a row meets a particular FormatCondition, you can override GridColumn's CellTemplate, add the Image control and bind its Source property using MultiValueConverter. In this converter, you can check whether the current row meets the FormatCondition using ExpressionEvaluator and return the required icon. I have attached a sample project to demonstrate this approach. Another way is to change the Image's Source property using DataTrigger or MultiDataTrigger with a similar converter, which will return the required "icon type".
        As for moving the ConditionalFormatting menu to another location, our ConditionalFormatting menu is created from the column's header semi-manually using our internal mechanisms. So, the only way to fully recreate this menu in a Bar is to create a class, which implements the IConditionalFormattingDialogBuilder interface. Then, override the CreateBarButtonItem, CreateBarSplitButtonItem and CreateBarSubItem methods to provide the BarItem creation logic. Finally, create a ConditionalFormattingDialogDirector class instance using your custom class and call the ConditionalFormattingDialogDirector's CreateMenuItems method. You can see this approach in the attached sample.

        Thanks,
        Kirill

          Comments (2)
          RH RH
          Roland Harrison 6 years ago

            Why is this the case? Surely allowing the conditional formatting to apply to the entire grid would be more performant than a new FormatCondition for each column?

            Kirill (DevExpress Support) 6 years ago

              Hello,
              I agree that providing a way to define FormatConditions for the entire GridControl or for a range of columns might be useful in certain cases, so I have passed to our developers that you're interested in this feature. At the same time, due to our Conditional Formatting implementation, evaluating such FormatConditions rather than conditions defined for separate columns won't bring performance benefits to GridControl.
              In any case, we're considering implementing such support in our future versions, however, we cannot guarantee that it will be implemented in the nearest releases.

              Thanks,
              Kirill

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.