PDA

View Full Version : Suggestion for ReportControl - Process_Rows



chuckatkinson
5-Aug-2009, 03:15 PM
Ian,

I recently had a problem with Process_Rows where a group row was selected (amongst others) and when it went to Process_Rows it blew up because GroupRows do not have a Comtag.

I made the following changes to my own Process_Rows procedure (in my object code)


If (ComSelected(hoRow)) Begin
Get ComRecord of hoRow to vRec
Set pvComObject of hoRec to vRec

Get ComGroupRow of hoRow to bGroupRow

If (not(bGroupRow)) Begin
Get ComTag of hoRec to sID


Wondering if this has popped up before for anyone else? It would be nice if I could prevent the user from selecting a grouprow ... ???

Nicole Wright
5-Aug-2009, 05:19 PM
Hi Chuck,

A problem also occurs when the export to csv with Grouped row on screen, I replaced the export with my own mixin, a snapshot of part of the code is found below, this code also exports columns in the same order as shown i.e. if they have been moved by the user, or hidden.



/////////////////////////////////////////////////////////////
// CSV Export
Procedure Write_CSV_File Integer iChannel
Boolean bComma bColumnVisible
Integer iCount iRow iColumn iColumn_Count iWidth iItemIndex
RowID Row_ID
String sID sValue
Handle hoReport_Rows hoRow hoRec hoItem hoGroupRow hoColumns hoColumn
Variant vReport_Rows vRow vRec vItem vColumns vColumn
tdRC_Column_Def[] tColumn_Defs
Get phoReportSelectedRows to hoReport_Rows
Get phoReportRow to hoRow
Get phoReportRecord to hoRec
Get phoReportRecordItem to hoItem
Get phoReportGroupRow to hoGroupRow
Get phoReportColumns to hoColumns
Get phoReportColumn to hoColumn

Get ptColumn_Defs to tColumn_Defs
Get piColumn_Count to iColumn_Count
Get ComSelectedRows to vReport_Rows
Set pvComObject of hoReport_Rows to vReport_Rows
Get ComColumns to vColumns
Set pvComObject of hoColumns to vColumns

Send WriteCSVHeading iChannel

Get ComCount of hoReport_Rows to iCount
Decrement iCount
For iRow from 0 to iCount
Get ComRow of hoReport_Rows iRow to vRow
Set pvComObject of hoRow to vRow
If (ComSelected(hoRow)) Begin
If (ComGroupRow(hoRow)) Begin
Set pvComObject of hoGroupRow to vRow
Get ComGroupCaption of hoGroupRow to sValue
Write channel iChannel ('"' + String(sValue) + '"')
End
Else Begin
Get ComRecord of hoRow to vRec
Set pvComObject of hoRec to vRec

Move (False) to bComma
For iColumn from 0 to iColumn_Count
Get ComColumn of hoColumns iColumn to vColumn
Set pvComObject of hoColumn to vColumn
Get ComVisible of hoColumn to bColumnVisible
Get ComItemIndex of hoColumn to iItemIndex
If (bColumnVisible) Begin
Get ComItem of hoRec iItemIndex to vItem
Set pvComObject of hoItem to vItem
Get ComCaption of hoItem to sValue
Move (Replaces(CLF,sValue,' ')) to sValue
If (tColumn_Defs[iItemIndex].iSize > 0) Begin
If (bComma) Write channel iChannel ","
Write channel iChannel ('"' + String(sValue) + '"')
Move (True) to bComma
End
End
Loop
End
Writeln channel iChannel ""
End
Loop
End_Procedure

Procedure WriteCSVHeading Integer iChannel
Boolean bComma bColumnVisible
Integer iColumn iColumn_Count iItemIndex
tdRC_Column_Def[] tColumn_Defs
String sHeader
Handle hoColumns hoColumn
Variant vColumns vColumn

Get ptColumn_Defs to tColumn_Defs
Get piColumn_Count to iColumn_Count
Get phoReportColumns to hoColumns
Get phoReportColumn to hoColumn
Get ComColumns to vColumns
Set pvComObject of hoColumns to vColumns
// Output header
Move (False) to bComma
For iColumn from 0 to iColumn_Count
Get ComColumn of hoColumns iColumn to vColumn
Set pvComObject of hoColumn to vColumn
Get ComVisible of hoColumn to bColumnVisible
Get ComItemIndex of hoColumn to iItemIndex
If (bColumnVisible) Begin
If (tColumn_Defs[iItemIndex].iSize > 0) Begin
If (bComma) Write channel iChannel ","
Move (String(tColumn_Defs[iItemIndex].sLabel)) to sHeader
Write channel iChannel ('"' + sHeader + '"')
Move (True) to bComma
End
End
Loop
Writeln channel iChannel ""

End_Procedure

Ian Smith
6-Aug-2009, 04:48 AM
HI Chuck

I thought we had handled this. I'll check it out.

Regards

chuckatkinson
6-Aug-2009, 08:34 AM
Hi Chuck,

A problem also occurs when the export to csv with Grouped row on screen, I replaced the export with my own mixin, a snapshot of part of the code is found below, this code also exports columns in the same order as shown i.e. if they have been moved by the user, or hidden.



Thanks Nick, I'll check it out. We had this problem early on too. I had added a Expand_All routine (and Collapse_All) to the my sub-class, so I simply called this prior to export. That seemed to fix the problem. I will look at your code for possible replacement.

Thanks - I really like the collaboration that is on-going with these controls.

Ian Smith
15-Aug-2009, 08:04 AM
Hi

Update in SVN

Added checks for Groups Rows into methods Process_Rows and CSV_Export