I have the following code:
var colHeaders = [
"Column 1",
"Column 2"
];
var columns = [
{data: 'column_1', validator: validatorRentalCode, allowEmpty: false, allowInvalid: false},
{data: 'column_2', type: 'numeric', numericFormat: typeNumber, allowEmpty: false},
];
var options = {
columns: columns,
colHeaders: colHeaders
};
div = document.querySelector('#table');
var table = new Table(div, options);
How variables are part of the context of the Table Object. I would like to improve and transform the variables into parameters as below:
var Table = {
TABLE: {
HEADERS: [
"Column 1",
"Column 2"
],
COLUMNS: [
{data: 'horas_extras', type: 'time', timeFormat: 'hh:mm', correctFormat: true, allowEmpty: false}
]
},
OPTIONS: {
columns: this.TABLE.COLUMNS,
colHeaders: this.TABLE.HEADERS
}
};
In this my change ended up with a undefined
: Cannot read property 'COLUMNS' of undefined
. Because I have a basic knowledge of the language, I believe that the COLUMNS
property does not exist at the moment of object creation.
What would be the best way to solve this problem?