Skip to content

Latest commit

 

History

History
59 lines (42 loc) · 1.62 KB

File metadata and controls

59 lines (42 loc) · 1.62 KB
sidebar_label beforeValueChange
title beforeValueChange event
description You can learn about the beforeValueChange 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.

beforeValueChange

:::caution The beforeValueChange 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 === "setCellValue") {
        console.log(actionName, config);
        return false;
    }
});

For more details about the new concept, see Spreadsheet actions. :::

Description

@short: Fires before the values of cells are changed

Usage

beforeValueChange: (cell: string, value: string) => void | boolean;

Parameters

The callback of the event takes the following parameters:

  • cell - (required) the id of a cell
  • value - (required) the value of a cell

Returns

Return true to change the value of a cell, false to prevent changing of value

Example

const spreadsheet = new dhx.Spreadsheet("spreadsheet", {});
spreadsheet.parse(data);

// subscribe on the "beforeValueChange" event
spreadsheet.events.on("beforeValueChange", function(cell, value){
    console.log("Value of cell "+ spreadsheet.selection.getSelectedCell()+" will change");
    console.log(cell, value);
    return true;
});

Related articles: Event handling