Saltar para o conteúdo principal
Versão: v20 R2 BETA

Programação avançada com Javascript

A 4D View Pro Area is a Web Area form object that uses the embedded web rendering engine. As such, it behaves just like any other web area, and you can get it to execute Javascript code by calling the WA Evaluate Javascript 4D command.

Since 4D View Pro is powered by the SpreadJS spreadsheet solution, you can also call SpreadJS Javascript methods in 4D View Pro areas.

Exemplo prático: Esconder a faixa de opções

Since 4D View Pro is a web area, you can select a webpage element and modify its behavior using Javascript. The following example hides the spreadJS Ribbon:

//Button's object method

var $js; $answer : Text

$js:="document.getElementsByClassName('ribbon')[0].setAttribute('style','display: none');"

$js+="window.dispatchEvent(new Event('resize'));"

$answer:=WA Evaluate JavaScript(*; "ViewProArea"; $js)

Chamar métodos Transcriptase do SpreadJS

You can tap into the SpreadJS library of Javascript methods and call them directly to control your spreadsheets.

4D has a built-in Utils.spread expression that points at the spreadsheet (also called workbook) inside the 4D View Pro area, making it simpler to call the SpreadJS Workbook methods.


O código seguinte anula a última ação na folha de cálculo:

WA Evaluate JavaScript(*; "ViewProArea"; "Utils.spread.undoManager().undo()")

Repositório 4D View Pro Tips

4D-View-Pro-Tips is a GitHub repository that contains a project full of useful functions, allowing to manage floating pictures, sort columns or rows, create a custom culture, and much more! Sinta-se à vontade para o clonar e experimentar com o projeto.