Ticket Q504781
Visible to All Users

Master/Detail grid with StyleFormatCondition

created 12 years ago

Hi again

I have a master/detail grid I'm using for data entry. Using Style format conditions on the detail gridview I'm able to alert the user to certain things that may need their attention through changing row colors. This is all working really well.

The problem is though, being a Master/Detail grid the detail view is not always expanded. Because of this, the end user isn't able to see any rows with an active format condition when the master row is collapsed.

What would be the best approach to highlight a row in the master gridview if there are any child rows that have met the format conditions in the detail view?

Thanks

Answers approved by DevExpress Support

created 12 years ago (modified 11 years ago)

Hello,
To achieve this goal, handle the GridView.RowStyle event for a master view. Here, you need to check the style condition at the data source level. For example:

C#
void gridView1_RowStyle(object sender, RowStyleEventArgs e) { foreach (StyleFormatCondition style in gridView2.FormatConditions) { DataView view = ds.Tables[1].DefaultView; int id = Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ItemID")); view.RowFilter = style.Expression + "AND [ItemID] = " + id.ToString(); if (view.Count > 0) e.Appearance.BackColor = style.Appearance.BackColor; } }
Visual Basic
Private Sub gridView1_RowStyle(ByVal sender As Object, ByVal e As RowStyleEventArgs) For Each style As StyleFormatCondition In gridView2.FormatConditions Dim view As DataView = ds.Tables(1).DefaultView Dim id As Integer = Convert.ToInt32(gridView1.GetRowCellValue(e.RowHandle, "ItemID")) view.RowFilter = style.Expression & "AND [ItemID] = " & id.ToString() If view.Count > 0 Then e.Appearance.BackColor = style.Appearance.BackColor End If Next style End Sub

In this sample the "ds" variable is of the DataSet type and the ds.Tables[1] table is a child table. Please see the attached project for more details.
Is this exactly what you are looking for? I hope to hear from you soon.

    Comments (3)

      Thanks Andrew, would of worked perfectly if I hadn't applied a style to the grid view. Seems as soon as that is done, it overrides e.Appearance.BackColor = style.Appearance.BackColor.

        Found e.HighPriority = True. Now everything working perfectly

        Andrew Ser (DevExpress Support) 12 years ago

          Hi,
              I'm glad to hear that you have resolved this issue. Please feel free to contact us if you have any difficulties.

          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.