| sidebar_label | beforeClear |
|---|---|
| title | beforeClear event |
| description | You can learn about the beforeClear event 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. |
:::caution The beforeClear event has been deprecated in v4.3. The event will continue work, but you'd better apply a new approach:
spreadsheet.events.on("beforeAction", (actionName, config) => {
if (actionName === "clear") {
console.log(actionName, config);
return false;
}
});For more details about the new concept, see Spreadsheet actions. :::
@short: Fires before a spreadsheet is cleared
beforeClear: () => void | boolean;Return false to prevent clearing a spreadsheet; otherwise, true.
const spreadsheet = new dhx.Spreadsheet("spreadsheet", {});
spreadsheet.parse(data);
// subscribe on the "beforeClear" event
spreadsheet.events.on("beforeClear", function(){
console.log("A spreadsheet will be cleared");
return false;
});Changelog: Added in v4.2
Related articles: Event handling