0
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);
As 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 there ended up occurring a undefined
: Cannot read property 'COLUMNS' of undefined
. Because I have a basic knowledge of language, I believe the property COLUMNS
does not exist at the time of the creation of the object.
What would be the best way to solve this problem of mine?