Skip to content

Commit 7f192ea

Browse files
committed
Add missing doc at root
1 parent 10f419c commit 7f192ea

32 files changed

+1493
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Advanced programming with Javascript
2+
3+
A 4D View Pro Area is a [Web Area form object](../FormObjects/webArea_overview.md) that uses the [embedded web rendering engine](../FormObjects/properties_WebArea.md#use-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`](../commands%20legacy/wa%20evaluate%20javascript.md) 4D command.
4+
5+
Since 4D View Pro is powered by the [SpreadJS spreadsheet solution](https://developer.mescius.com/spreadjs), you can also call SpreadJS Javascript methods in 4D View Pro areas.
6+
7+
## Hands-on example: Hiding the Ribbon
8+
9+
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](./configuring.md#ribbon):
10+
11+
```4d
12+
//Button's object method
13+
14+
var $js; $answer : Text
15+
16+
$js:="document.getElementsByClassName('ribbon')[0].setAttribute('style','display: none');"
17+
18+
$js+="window.dispatchEvent(new Event('resize'));"
19+
20+
$answer:=WA Evaluate JavaScript(*; "ViewProArea"; $js)
21+
```
22+
23+
## Calling SpreadJS Javascript methods
24+
25+
You can tap into the SpreadJS library of Javascript methods and call them directly to control your spreadsheets.
26+
27+
4D has a built-in `Utils.spread` property that gives access to the spreadsheet document (also called workbook) inside the 4D View Pro area, making it simpler to call the SpreadJS [Workbook methods](https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Sheets.Workbook).
28+
29+
#### Example
30+
31+
The following code undoes the last action in the spreadsheet:
32+
33+
```4d
34+
WA Evaluate JavaScript(*; "ViewProArea"; "Utils.spread.undoManager().undo()")
35+
```
36+
37+
## 4D View Pro Tips repository
38+
39+
[4D-View-Pro-Tips](https://github.com/4d-depot/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! Feel free to clone it and experiment with the project.

0 commit comments

Comments
 (0)