Skip to content

Instantly share code, notes, and snippets.

@Ganbin
Last active August 19, 2020 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ganbin/6620b93163ffddd1c4ec3fb2ee0570b4 to your computer and use it in GitHub Desktop.
Save Ganbin/6620b93163ffddd1c4ec3fb2ee0570b4 to your computer and use it in GitHub Desktop.
Custom 4D View Pro methods. A container to write your own SpreadJS code inside a 4D View Pro area
// VP_customMethod ( $params )
//
// $params : (object) The params objet must contain the "case" attribute that will allow you to execute the needed code
// You also need a "name" attribute to set the name of the view pro area
// Depending the case you can add your custom attributes
//
// The purpose of this method is to execute some special method that are not yet available in 4D v18
If (False)
// ----------------------------------------------------
// User name (OS): gabriel inzirillo
// Date and time: 13.07.20, 13:23:27
// ----------------------------------------------------
// Method: VP_customMethod
// Description
// The purpose is to have a single place where you execute your custom VP method, because most of the time we need the same instance (spread and sheet)
// So it is easier to write the code one time and depending on what we need to write specific code in the case of
//
//
// ----------------------------------------------------
End if
C_OBJECT($1;$params)
C_TEXT($Txt_js;$viewProName)
C_VARIANT($0)
$params:=$1
$viewProName:=$params.name
$Txt_js:="var spread = GC.Spread.Sheets.findControl(document.getElementById('ss'));"\
+"var sheet = spread.getActiveSheet();"
Case of
: ($params.case="getColumnWidth") // Get the column width -> available in R3 as a native View Pro Command
$Txt_js:=$Txt_js+"sheet.getCell(-1,"+String($params.cell.column)+").width()"
$0:=WA Evaluate JavaScript(*;$viewProName;$Txt_js;Is longint)
: ($params.case="setColumnWidth") // Set the column width -> available in R3 as a native View Pro Command
$Txt_js:=$Txt_js+"sheet.getCell(-1,"+String($params.cell.column)+").width("+String($params.value)+")"
$0:=WA Evaluate JavaScript(*;$viewProName;$Txt_js)
: ($params.case="VP_PRINT") // Print the View Pro -> Available in v18
$Txt_js:=$Txt_js+"spread.print(0)" // Print the first sheet. More info (https://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Sheets.Workbook~print.html)
$0:=WA Evaluate JavaScript(*;$viewProName;$Txt_js)
End case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment