Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/awaitredraw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
sidebar_label: AwaitRedraw helper
title: AwaitRedraw helper
description: You can explore the AwaitRedraw helper in the documentation of the DHTMLX JavaScript Spreadsheet library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX Spreadsheet.
---

# AwaitRedraw helper

Some API methods of DHTMLX Spreadsheet take effect only after the component is rendered on the page. In some cases this can take a moment, so you need to wait until the browser completes rendering before running the next piece of code.

For such cases, you can use the **dhx.awaitRedraw** helper. It tracks the rendering cycle and runs your code as soon as Spreadsheet completes its rendering.

~~~js
dhx.awaitRedraw().then(() => {
// your code here
});
~~~

For example, use `awaitRedraw` inside `afterDataLoaded` to make sure the cell value is available before reading it:

~~~js
spreadsheet.events.on("afterDataLoaded", () => {
dhx.awaitRedraw().then(() => {
const value = spreadsheet.getValue("A1");
console.log(value);
});
});
~~~

3 changes: 2 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ module.exports = {
"themes/custom_theme"
]
},
"using_typescript"
"using_typescript",
"awaitredraw"
]
},
{
Expand Down