Hi Pat,
When there is no 4D command to do something in 4D Write Pro, try javascript.
I suggest using an anomymous javascript function.
Build your javascript code using a 4D Object with the “New formula” command.
The basic shell — for an anonymous javascript function in 4D code — is the
following 4-lines:
—
$js:=New object("val";"";"add";New formula(This.val:=This.val+$1))
$js.add("(function(){“)
// Your javascript code will go between these 2-lines: immediately above and
below this comment.
$js.add("})();")
$t:=WA Evaluate JavaScript(*;$objName_vp_t;$js.val;Is text)
—
You then add as many “js.add(“”) lines as necessary to write javascript to
accomplish the spread sheet behavior you want.
Here’s how I set a column width to a specific size. The size is in points.
—
// local
C_OBJECT($js)
C_TEXT($t)
// parameter
C_TEXT($1;$objName_vp_t) // write pro view object name
C_LONGINT($2;$column_number_i) // column number
C_LONGINT($3;$column_width_i) // column width (in points)
$objName_vp_t:=$1
$column_number_i:=$2
$column_width_i:=$3
$js:=New object("val";"";"add";New formula(This.val:=This.val+$1))
$js.add("(function(){")
$js.add("var sheet = Utils.currentSheet;")
$js.add("sheet.setColumnWidth("+String($column_number_i)+",
"+String($column_width_i)+",GC.Spread.Sheets.SheetArea.viewport);")
$js.add("})();")
$t:=WA Evaluate JavaScript(*;$objName_vp_t;$js.val;Is text)
—
Details on “setColumnWidth” are at:
https://help.grapecity.com/spread/SpreadSheets11/webframe.html#autofit.html
<https://help.grapecity.com/spread/SpreadSheets11/webframe.html#autofit.html>
Best regards,
Jeremy
> On May 24, 2019, at 5:04 AM, Pat Bensky via 4D_Tech <[email protected]>
> wrote:
>
> How do you set a column width (via code) in View Pro?
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************