This is a migrated thread and some comments may be shown as answers.

Expression Based Conditional Formatting on Child Rows

1 Answer 189 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Dec 2012, 11:11 AM
Hi,

I have conditional formatting rules on a parent grid that are defined as expression types 

New ExpressionFormattingObject ("COL1",Expression:="COL2 = 1", etc.)

The compare data is in a different column than the formatting. This works OK for the Grid.MasterTemplate.Columns.

I also have identical rules defined for Grid.MasterTemplate.Templates(0).Columns, however the styling does not get applied for these rows on the child grid. If I change the child rules to be ConditionalFormattingObject type as:

New ConditionalFormattingObject ("COL1", Equals, Value:="1", etc.)

the styles are applied correctly. I can't do this though as the data item is in a different column than the formatting. (test against COL1, style COL2)

Is there something I need to do to get the expression rules to format correctly?

Many thanks,

Mark.

1 Answer, 1 is accepted

Sort by
0
Accepted
Julian Benkov
Telerik team
answered on 26 Dec 2012, 01:06 PM
Hello Mark,

Thank you for writing.

I found an issue in the ExpressionFormatingObject Evaluate implementation. The issue is logged to our Public Issue Tracking System and the fix will be available in our next release. Currently, you can use this override of ExpressionFormattingObject as workaround:
Private Sub GridHierarchyCRUDForm_Load(sender As Object, e As EventArgs)
    ' TODO: This line of code loads data into the 'nwindDataSet.Orders' table. You can move, or remove it, as needed.
    Me.ordersTableAdapter.Fill(Me.nwindDataSet.Orders)
    ' TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.
    Me.customersTableAdapter.Fill(Me.nwindDataSet.Customers)
 
    Dim formatObj As BaseFormattingObject = New MyExpressionFormattingObject("ShipVia", "ShipVia = 1", False)
    formatObj.CellBackColor = Color.Red
    Me.radGridView1.Templates(0).Columns(6).ConditionalFormattingObjectList.Add(formatObj)
End Sub
 
Private Class MyExpressionFormattingObject
    Inherits ExpressionFormattingObject
    Public Sub New(name As String, expression As String, applyToRow As Boolean)
 
        MyBase.New(name, expression, applyToRow)
    End Sub
 
    Public Overrides Function Evaluate(row As GridViewRowInfo, column As GridViewColumn) As Boolean
        If Not MyBase.Enabled OrElse [String].IsNullOrEmpty(Me.Expression) Then
            Return False
        End If
 
        Dim result As Object = row.ViewTemplate.ListSource.CollectionView.Evaluate(Me.Expression, New GridViewRowInfo() {row})
        Return If(TypeOf result Is Boolean, CBool(result), False)
    End Function
End Class

I hope this helps. 

Thank you for the report. Your Telerik points have been updated.

Regards,
Julian Benkov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or