Custom data handsontable
by Alexandre Froger
JavaScript
var CustomDataHot = (function () {
/*Constructor*/
function CustomDataHot (data) {
if(typeof data !== "undefined"){
this._dataHot = data;
}else{
setDefaultData.call(this);
}
this._triggerUpdateDataName = null;
}
/*Private method*/
/**
* Set default value in dataHot array.
* @return {_dataHot} The object dataHot.
*/
function setDefaultData () {
this._dataHot = {
options: {
/*Cols properties*/
cols: [
null,
{name : "Série 1",color : "",type : "area"},
{name : "Série 2",color : "",type : "area"}
],
/*Rows properties*/
rows: [
null,
null,
null
],
/*Cells properties*/
cells: [
[null, null, null],
[null, null, null],
[null, null, null]
]
},
values: [
[null, null, null],
[null, null, null],
[null, null, null]
]
};
}
/**
* Launch function name if defined
*/
function triggerUpdateData() {
if(this._triggerUpdateDataName !== null && typeof this._triggerUpdateDataName == "function"){
this._triggerUpdateDataName.call();
}
}
/*Public method*/
/**
* Get the custom data formatted.
* @return {_dataHot} The object dataHot.
*/
CustomDataHot.prototype.getData = function () {
return this._dataHot;
}
/**
* Update values.
* @param {values} values to change
*/
CustomDataHot.prototype.updateValues = function (values) {
this._dataHot.values = values;
triggerUpdateData.call(this);
}
/**
* Update option col.
* @param {col} current col number
* @param {value} value to change
*/
CustomDataHot.prototype.updateOptionsCols = function (col, value) {
this._dataHot.options.cols[col] =...