Skip to Content
0
Dec 04, 2014 at 09:31 AM

Collapsed rows give unexpected results in a grid

444 Views

Hi,

For learning purposes, I am working on the sample which comes with SDK called: 19.Grid.


I have modified the basic sample as follows:

  • I have added a checkbox column
  • I have added code to color the row which is ticked. It ticked = blue, if unticked = gray
  • I retained only 2 collapse levels:
    • CollapseLevel = 0 for the radiobutton "No Grouping"
    • CollapseLevel = 1 for the radiobutton "Card Code"

The relevant code I used is shown at the bottom of this thread.

oGrid.CommonSetting.SetRowBackColor(pVal.Row + 1, newColor)


When I group on Card Code and Expand all rows, the code for background color works fine:

When I tick any checkbox, the row becomes blue.

When I untick the checkbox, the row returns to gray.

No problem at all here..

------------------------------------------

Problem:

Problems arise when some rows are collapsed.

The attached picture explains the problem better than words.

It seems that when there are collapsed rows ABOVE the relevant checkbox, then pVal.Row is not working properly.

If I expand all rows, the rows are correctly colored when I tick a checkbox.

--------------------------------------

Request:

Anybody knows what is happening, and propose a solution?

Thanks

Leon Lai

------------------------------------------------

Picture:

--------------------------------------------------------

Relevant Code: (in SBO_Application > ItemEvent)



Private Sub SBO_Application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.ItemEvent

BubbleEvent = True

Dim EventEnum As SAPbouiCOM.BoEventTypes

EventEnum = pVal.EventType

If (FormUID = "frmGrid") And ((pVal.ItemUID = "optNo") Or _

(pVal.ItemUID = "optCode")) And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) And (pVal.BeforeAction = False) Then

If (userDS.Value = 1) Then

oForm.Freeze(True)

DocStatus, U_HandOver, ShipToCode from OINV where U_HandOver IS NULL and ShipToCode NOT LIKE '%Address' ")

oForm.DataSources.DataTables.Item(0).ExecuteQuery("Select TOP 3000 CardCode, CardName, DocDate, DocEntry, DocNum, DocTotal, DocStatus, U_HandOver, ShipToCode from OINV where U_HandOver IS NULL ")

oGrid.Columns.Item("U_HandOver").Type = SAPbouiCOM.BoGridColumnType.gct_CheckBox

oGrid.CollapseLevel = 0

oForm.Freeze(False)

ElseIf (userDS.Value = 2) Then

oForm.Freeze(True)

oForm.DataSources.DataTables.Item(0).ExecuteQuery("Select TOP 3000 CardCode, CardName, DocDate, DocEntry, DocNum, DocTotal, DocStatus, U_HandOver, ShipToCode from OINV where U_HandOver IS NULL ")

oGrid.Columns.Item("U_HandOver").Type = SAPbouiCOM.BoGridColumnType.gct_CheckBox

oGrid.CollapseLevel = 1

oForm.Freeze(False)

End If

End If

If (FormUID = "frmGrid") And (pVal.BeforeAction = False) And _

(pVal.EventType = SAPbouiCOM.BoEventTypes.et_CLICK) And _

((pVal.ItemUID = "btnCol") Or (pVal.ItemUID = "btnExp")) Then

If (pVal.ItemUID = "btnCol") Then

oGrid.Rows.CollapseAll()

End If

If (pVal.ItemUID = "btnExp") Then

oGrid.Rows.ExpandAll()

End If

End If

If FormUID = "frmGrid" And pVal.BeforeAction = False _

And pVal.EventType = SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED _

And pVal.ColUID = "U_HandOver" Then

Dim newColor As Integer = If(oGrid.DataTable.GetValue("U_HandOver", oGrid.GetDataTableRowIndex(pVal.Row)).ToString() = "Y", 16777088, 15198183)

oGrid.CommonSetting.SetRowBackColor(pVal.Row + 1, newColor)

End If

Attachments

Capture.JPG (151.7 kB)