Skip to content

Latest commit

 

History

History
64 lines (44 loc) · 1.75 KB

File metadata and controls

64 lines (44 loc) · 1.75 KB
sidebar_label beforeFormatChange
title beforeFormatChange event
description You can learn about the beforeFormatChange 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.

beforeFormatChange

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

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

Description

@short: Fires before the format of a cell is changed

Usage

beforeFormatChange: (cell: string, format: string) => void | boolean;

Parameters

The callback of the event takes the following parameters:

  • cell - (required) the id of a cell
  • format - (required) a new format applied for a cell

Returns

Return true to change the format, false to prevent changing of the format

Example

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

// subscribe on the "beforeFormatChange" event
spreadsheet.events.on("beforeFormatChange", function(cell, format){
    console.log("Format of cell "+spreadsheet.selection.getSelectedCell()+" will change");
    console.log(cell, format);
});

Related articles:

Related sample: Spreadsheet. Events