Module SigCJReportControlDemo - TreeView.vw
1Use Windows.pkg
2Use DFClient.pkg
3Use cSigCjReportControl.pkg
4Use Vendor.DD
5Use Invt.DD
6
7Struct tdReportGroup
8 String sGroupName
9 Integer iCount
10 Boolean bExpanded
11End_Struct
12
13Deferred_View Activate_oSigCJReportControlDemo_TreeView for ;
14Object oSigCJReportControlDemo_TreeView is a dbView
15
16 Set Border_Style to Border_Thick
17 Set Size to 292 386
18 Set Location to 10 17
19 Set piMinSize to 292 386
20 Set Label to "Codejock Demo - Report Control - Tree View"
21 Set Icon to "SIG.ico"
22
23 Object oSigCJReportControl1 is a cSigCJReportControl
24
25 Property tdReportGroup[] ptaReportGroup
26
27 Property Integer piImageFolderClosed
28 Property Integer piImageFolder
29 Property Integer piImageAbout
30
31 Set Size to 223 376
32 Set Location to 33 6
33 Set peAnchors to anAll
34 //Set data source to text, even though we will populate it with data from the db
35 Set peDb_Type to eRC_db_Text
36 //Set pbRow_Item to True so that the OnCreateRowItem event is called
37 Set pbRow_Item to True
38 //Don't show the group box - we will group programatically
39 Set pbShowGroupBox to False
40 //Set Row_Colors to True. Not because we want row Colors, but we need to turn on the OnComBeforeDrawRow event
41 Set pbRow_Colors to True
42 //Set reference column
43 Set piRef_Column to 4
44 //Turn off the auo row ref. We will use a serialised row id as the reference (specified in the piRef_Column)
45 Set pbAuto_Row_Ref to False
46
47
48 //Method to keep track of group labels and the count of items within the group
49 Procedure Increment_Group_Count String sGroup
50 tdReportGroup[] taReportGroup
51 Integer iGroup
52 Boolean bFoundGroup
53
54 Get ptaReportGroup to taReportGroup
55 For iGroup from 0 to (SizeOfArray(taReportGroup)-1)
56 If (taReportGroup[iGroup].sGroupName = sGroup) Begin
57 Add 1 to taReportGroup[iGroup].iCount
58 Move True to bFoundGroup
59 Move (SizeOfArray(taReportGroup)-1) to iGroup
60 End
61 Loop
62 If (not(bFoundGroup)) Begin
63 Move (SizeOfArray(taReportGroup)) to iGroup
64 Move sGroup to taReportGroup[iGroup].sGroupName
65 Add 1 to taReportGroup[iGroup].iCount
66 End
67 Set ptaReportGroup to taReportGroup
68 End_Procedure
69
70 //Method to return the number of items within a group (specified by the label)
71 Function Group_Count String sGroup Returns Integer
72 Integer iRetVal iGroup
73 tdReportGroup[] taReportGroup
74
75 Get ptaReportGroup to taReportGroup
76 For iGroup from 0 to (SizeOfArray(taReportGroup)-1)
77 If (taReportGroup[iGroup].sGroupName = sGroup) Begin
78 Move taReportGroup[iGroup].iCount to iRetVal
79 Move (SizeOfArray(taReportGroup)-1) to iGroup
80 End
81 Loop
82 Function_Return iRetVal
83 End_Function
84
85 //OnCreate. Set a few more properties that we don't (yet) have property wrappers for.
86 Procedure OnCreate
87 Forward Send OnCreate
88
89 Set ComAllowColumnReOrder to False
90 Set ComAllowColumnRemove to False
91 Set ComRecordsTreeFilterMode to OLExtpReportFilterTreeByParentAndChildren
92 Set ComHorizontalGridStyle of (phoReportPaintManager(Self)) to OLExtpGridNoLines
93 End_Procedure
94
95 Procedure OnDefine_Columns
96 Send Add_Report_Column "Description" 300 eRC_String eRC_Standard "" ""
97 Send Add_Report_Column "Unit Price" 90 eRC_Currency eRC_Standard "" ""
98 Send Add_Report_Column "On Hand" 90 eRC_Integer eRC_Standard "" ""
99 //Hidden column on which to group
100 Send Add_Report_Column "" 0 eRC_String eRC_Standard "" ""
101 End_Procedure
102
103 //Set the Tree Column
104 Procedure OnCreateColumn Integer iColumn Handle hoCol
105 If (iColumn=0) Begin
106 Set ComTreeColumn of hoCol to True
107 End
108 End_Procedure
109
110 //We are NOT opening a data source BUT we will use this suitable hook for clearing file buffers, initialising properties and loading icons
111 Procedure OnOpen_DataSource
112 Integer iIndex
113 tdReportGroup[] taReportGroup
114
115 Set pbEOF to False
116 Set ptaReportGroup to taReportGroup
117 //Add images
118 Get AddImage of ghoSigCjGlobalSetting "Misc_Folder_Closed.ico" 0 0 to iIndex
119 Set piImageFolderClosed to iIndex
120 Get AddImage of ghoSigCjGlobalSetting "Misc_Folder.ico" 0 0 to iIndex
121 Set piImageFolder to iIndex
122 Get AddImage of ghoSigCjGlobalSetting "Misc_about.ico" 0 0 to iIndex
123 Set piImageAbout to iIndex
124 //clear file buffer
125 Clear Invt
126 End_Procedure
127
128 //Find next record in db. Use Add_Item_Data to upload values we want displayed in the report control (plus an additional reference value)
129 Procedure OnPrepare_RowData
130 Find GT Invt by Index.2
131 If (not(Found)) Begin
132 Set pbEOF to True
133 End
134 Else Begin
135 Relate Invt
136 Send Add_Item_Data (Trim(Invt.Description))
137 Send Add_Item_Data Invt.Unit_Price
138 Send Add_Item_Data Invt.On_Hand
139 Send Add_Item_Data (Trim(Vendor.Name))
140 Send Add_Item_Data (SerializeRowID(GetRowID(Invt.File_Number)))
141 End
142 End_Procedure
143
144 //Add child items to a report item
145 Procedure DoAddChildDetail String sLabel String sData Handle hoChilds Handle hoChild Handle hoItem
146 Variant vItem
147
148 Set pvComObject of hoChild to (ComAdd(hoChilds))
149 Get ComAddItem of hoChild (sLabel*sData) to vItem
150 Set ComTag of hoChild to (SerializeRowID(GetRowID(Invt.File_Number)))
151 Set pvComObject of hoItem to vItem
152 Set ComIcon of hoItem to (piImageAbout(Self))
153 End_Procedure
154
155 //Use OnCreateRowItem to add additional child records. We don't need to do this every time the event is called, simply once per row
156 //..so we wait until the passed column is the last one in the row (iColumn=piColumn_Count)
157 Procedure OnCreateRowItem Integer iColumn Handle hoItem String sValue
158 Handle hoChilds hoChildRecord hoChildItem
159
160 If (iColumn=piColumn_Count(Self)) Begin
161 Send Increment_Group_Count (Trim(Vendor.Name))
162
163 Get Create U_cSigCJComReportRecords to hoChilds
164 Set pvComObject of hoChilds to (ComChilds(phoReportRecord(Self)))
165 Get Create U_cSigCJComReportRecord to hoChildRecord
166 Get Create U_cSigCJComReportRecordItem to hoChildItem
167
168 Send DoAddChildDetail "Vendor Part ID:" (Trim(Invt.Vendor_Part_ID)) hoChilds hoChildRecord hoChildItem
169 Send DoAddChildDetail "Item ID:" (Trim(Invt.Item_ID)) hoChilds hoChildRecord hoChildItem
170
171 Send Destroy of hoChildItem
172 Send Destroy of hoChildRecord
173 Send Destroy of hoChilds
174 End
175 End_Procedure
176
177 //Programmatically specify the ordering
178 Procedure OnSetGrouping tdRC_Ordering[] ByRef taRC_Ordering
179 Move 3 to taRC_Ordering[0].iColumn
180 End_Procedure
181
182 //Populate as normal but then process the rows so we can amend the group row labels
183 Procedure ComPopulate
184 Forward Send ComPopulate
185 Send DoProcessAllRows
186 End_Procedure
187
188 {MethodType=Event}
189 Procedure OnProcessRow Handle hoRow
190 End_Procedure
191
192 {MethodType=Event}
193 Procedure OnProcessGroupRow Handle hoRow
194 Handle hoRows
195 String sCaption
196 Boolean bExpanded
197 Integer iCount
198
199 Get ComGroupCaption of hoRow to sCaption
200 Move (Trim(sCaption)) to sCaption
201 If (Left(sCaption,1)=":") Begin
202 Move (Trim(Replace(":",sCaption,""))) to sCaption
203 End
204
205 Get Group_Count sCaption to iCount
206 Set ComExpanded of hoRow to False
207 Move (sCaption*"(%1)") to sCaption
208 Move (SFormat(sCaption,String(iCount))) to sCaption
209 Set ComGroupCaption of hoRow to sCaption
210 End_Procedure
211
212 {MethodType=Method Visibility=Public}
213 Procedure DoProcessAllRows
214 Handle hoRows hoRow hoGroupRow
215 Integer iRow iCount
216 Variant vRow
217 Boolean bIsGroupRow
218
219 If (not(IsComObjectCreated(Self))) Begin
220 Procedure_Return
221 End
222 Get phoReportRow to hoRow
223 Get phoReportGroupRow to hoGroupRow
224 Get phoReportRows to hoRows
225 Set pvComObject of hoRows to (ComRows(Self))
226 Get ComCount of hoRows to iCount
227 Subtract 1 from iCount
228 For iRow from 0 to iCount
229 Get ComRow of hoRows iRow to vRow
230 Set pvComObject of hoRow to vRow
231
232 Get ComGroupRow of hoRow to bIsGroupRow
233 If (bIsGroupRow) Begin
234 Set pvComObject of hoGroupRow to vRow
235 Send OnProcessGroupRow hoGroupRow
236 End
237 Else Begin
238 Send OnProcessRow hoRow
239 End
240 //Have to re-get the count because we may have collapsed a row
241 Get ComCount of hoRows to iCount
242 Subtract 1 from iCount
243 Loop
244 End_Procedure
245
246 //Set the group icons (folder images)
247 Procedure OnComBeforeDrawRow Variant llRow Variant llItem Variant llMetrics
248 Handle hoRow hoGroupRow hoMetrics
249 Boolean bIsGroupRow bExpanded
250 Integer iImage
251
252 Get phoReportRow to hoRow
253 Set pvComObject of hoRow to llRow
254 Move (IsNullComObject(ComRecord(hoRow))) to bIsGroupRow
255 If (bIsGroupRow) Begin
256 Get phoReportGroupRow to hoGroupRow
257 Set pvComObject of hoGroupRow to llRow
258 Get ComExpanded of hoGroupRow to bExpanded
259 Move (If(bExpanded,piImageFolder(Self),piImageFolderClosed(Self))) to iImage
260 Get Create U_cSigCJComReportRecordItemMetrics to hoMetrics
261 Set pvComObject of hoMetrics to llMetrics
262 Set ComGroupRowIcon of hoMetrics to iImage
263 Set ComGroupRowIconAlignment of hoMetrics to (olextpGroupRowIconBeforeText + olextpGroupRowIconVCenterToText)
264 Send Destroy of hoMetrics
265 End
266 End_Procedure
267
268 Procedure OnActive_Track String sID
269 Set value of oActive_Track_Row to sID
270 End_Procedure
271
272 End_Object
273
274 Object oGroup1 is a Group
275 Set Size to 29 378
276 Set Location to 1 4
277 Set peAnchors to anTopLeftRight
278
279 Object oActive_Track_cb is a CheckBox
280 Set Location to 12 10
281 Set Size to 10 50
282 Set Label to "Active Track"
283
284 Procedure OnChange
285 Boolean bChecked
286
287 Get Checked_State to bChecked
288 Set pbActive_Track of oSigCJReportControl1 to bChecked
289 End_Procedure
290
291 End_Object
292
293 Object oFilter_Search_Form is a Form
294 Set Size to 13 102
295 Set Location to 10 267
296 Set peAnchors to anBottomRight
297 Set Label_Col_Offset to 2
298 Set Label_Justification_Mode to JMode_Right
299 Set Label to "Filter Search"
300
301 Set Form_Button 0 to Form_Button_Prompt
302 Set Form_Button_Bitmap 0 to "ieref.bmp"
303 Set Prompt_Button_Mode to PB_PromptOn
304 On_Key kClear Send Prompt
305 On_Key kEnter Send Prompt
306
307 Procedure OnChange
308 String sValue
309
310 Get Value to sValue
311 If (Trim(sValue) = "") Begin
312 Send Filter_Rows of oSigCJReportControl1 sValue
313 End
314 End_Procedure
315
316 Procedure Prompt
317 String sValue
318
319 Get Value to sValue
320 Send Filter_Rows of oSigCJReportControl1 sValue
321 End_Procedure
322 End_Object
323
324 End_Object
325
326 Object oActive_Track_Row is a Form
327 Set Location to 264 25
328 Set Size to 13 52
329 Set Label to "Row"
330 Set Label_Justification_Mode to JMode_Right
331 Set Label_Col_Offset to 2
332 Set peAnchors to anBottomLeft
333 End_Object
334
335 Object oButton1 is a Button
336 Set Location to 267 329
337 Set Label to "ReLoad"
338 Set peAnchors to anBottomRight
339
340 // fires when the button is clicked
341 Procedure OnClick
342 Send Reset_Data_Properties of oSigCJReportControl1
343 Send Rebuild_Report of oSigCJReportControl1
344 End_Procedure
345
346 End_Object
347
348
349Cd_End_Object
350