CCJGrid custom row height

From DataFlex Wiki
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.

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