adds a custom function that will be used in formulas
name | string | the name of a new function in uppercase |
handler | function | the handler function |
$$("ss1").registerMathMethod("NEW", function(value){
// function's logic
});
The handler function can receive a set of parameters for your function. For example, you can pass one value (a cell reference) or an array of values (a range of cell values), etc.
You can use the new method as =NEW(H3:H5);
For the added math method you can add suggestions for its parameters by updating the webix.i18n.spreadsheet.liveEditor["functions-syntax"] locale.
Check the example below:
const ssheet = webix.ui({
view: "spreadsheet",
toolbar: "full"
});
ssheet.registerMathMethod("RANDOM", function(value){ value = value || 100; return Math.round(Math.random()*value); });
webix.i18n.spreadsheet.liveEditor["functions-syntax"].RANDOM = [ ["Digit", "Optional. The number digit."] ];
ssheet.setCellValue(1,1,"=RANDOM(100)")