CCJGrid custom row height

From DataFlex Wiki
Revision as of 13:12, 20 December 2022 by Wil (talk | contribs) (Cleanup code that isn't used (less is more))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Normally you can't set the row height for an individual row in a codejock grid.

The following code shows you how-to do that.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
Use Windows.pkg
Use DFClient.pkg
 
Use cCJGrid.pkg
Use cCJGridColumn.pkg
 
Deferred_View Activate_oListWithImage for ;
Object oListWithImage is a dbView
  Set Border_Style to Border_Thick
  Set Size to 332 591
  Set Location to 2 2
  Set Label to "ListWithImage"
   
  Object oThisProductList is a cCJGrid
    Set Size to 325 580
    Set Location to 4 5
     
    Set pbReadOnly to True
     
    Procedure OnComMeasureRow Variant llRow OLE_HANDLE llhDC Integer llWidth Integer ByRef llHeight
      Move 75 to llHeight
      Forward Send OnComMeasureRow llRow llhDC llWidth llHeight         
    End_Procedure
     
    Procedure ResetGrid
      Handle  hoPaint
      Integer iCustomDraw
      Boolean bIsVirtual bUseFocusCell
      Boolean bFixed
       
      Get phoReportPaintManager to hoPaint
      Forward Send ResetGrid
      Get pbUseFocusCellRectangle to bUseFocusCell
      Move 0 to iCustomDraw
      If bUseFocusCell Begin
          Move (xtpCustomDrawItem) to iCustomDraw
      End
      Move (iCustomDraw ior xtpCustomBeforeDrawRow ior xtpCustomMeasureRow) to iCustomDraw
       
      Get ComFixedRowHeight of hoPaint to bFixed // ComSetCustomDraw resets this to True, must be restored
      Send ComSetCustomDraw iCustomDraw
      Set ComFixedRowHeight of hoPaint to bFixed
    End_Procedure
     
    Object oSTMAS_THUMBNAIL is a cCJGridColumn
      Set piWidth to 100
      Set pbEditable to False
      Set pbMultiLine to True
       
      Function DisplayImage String sImageName Returns String
        String  sXAML
         
        Move "" to sXAML
        Append sXAML '<StackPanel  HorizontalAlignment="Center" Name="Grid1" VerticalAlignment="Top">'
        Append sXAML   '<Border HorizontalAlignment="Center" Name="Border1" VerticalAlignment="Top" Background="White" BorderBrush="#FF1FA3EB" BorderThickness="0,0,0,0">'
        Append sXAML     '<Image Name="Image1" Stretch="Uniform" Width="75px" Height="75px" Source="%1" />'
        Append sXAML   '</Border>'
        Append sXAML '</StackPanel>'
         
        Move (SFormat(sXAML, sImageName)) to sXAML
        Function_Return sXAML
      End_Function
       
      Procedure OnCreateColumn
        Forward Send OnCreateColumn
        Delegate Set ComEnableMarkup to True
      End_Procedure
    End_Object
 
    Object oSTMAS_CODE is a cCJGridColumn
      Set piWidth to 197
      Set psCaption to "Product"
      Set pbEditable to False
    End_Object
     
    Procedure LoadData
      tDataSourceRow[] MyData
      String sXAML
      String sPath
       
      Send ResetGrid
      Get psBitmapPath of (phoWorkspace(ghoApplication)) to sPath
      Get DisplayImage of oSTMAS_THUMBNAIL (sPath+"\01.01.01_t.jpg") to sXAML // Put the image in the bitmap path
       
      Move sXAML      to MyData[0].sValue[0]
      Move "01.01.01" to MyData[0].sValue[1]
       
      Send ReInitializeData MyData False
    End_Procedure
     
    Procedure Activating
      Forward Send Activating
      Send LoadData
    End_Procedure
  End_Object
 
Cd_End_Object

See also: cCJGrid Row Height