Exclusively assign a value to a shared variable
Hi I have the following function,
private _setupTimeDayVal(days:any, times: any, data?: any){
let timeData: Array<any> = [];
for (let x in times){
let timing: any = {};
for (let y in days){
if (days[y] == 'time'){
timing[days[y]] = (typeof days[y] != 'undefined') ? times[x] : undefined;
timeData.push(timing);
this._rowResult = this._agSvc.setRowResult(timeData);
}else {
this._rowResult = this._agSvc.setRowResult(data);
}
}
}
this._gridOptions.rowData = this._rowResult;
}
The function takes 3 parameters. I check if one of the values ββin the days array time
is one of the columns in my table (ag-grid), then I create an object and click on an empty array and assign it to a variable named _rowResult
.
And at the end of the loop, I assign the value to _rowResult
my named shared variable this._gridOptions.rowData
, which I use to pass as a table to a table (ag-grid).
But he always gives me the data operator else
(used to add value to my other columns, except for the time column) this._rowResult = this._agSvc.setRowResult(data);
.
But I want to improve this code so that my time column is filled with the data of the if statement and the other columns have to fill the else statement. Any ideas guys? Thanks in advance.
source to share
No one has answered this question yet