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 in 3 parameters. Am checking whether one of the value in days array is time
, it is one of the column in my table (ag-grid), then I create an object and push to empty array and assign it into a variable named _rowResult
.
And at the end of the loop I assign the _rowResult
value into my common variable named this._gridOptions.rowData
which am used to pass as data into my table(ag-grid).
But its always passing me the else
statement data(used to to add value to my other columns except the time column), this._rowResult = this._agSvc.setRowResult(data);
.
But I want to improve this code so that my time column will be filled with the if statement data and other columns need to fill with the else statement. Any idea guys? Thanks in advance.