|
<div class="row">
<ejs-pivotview #pivotview id='PivotView' [dataSourceSettings]=dataSourceSettings showTooltip='false' width='100%'
height='300' [gridSettings]='gridSettings' [editSettings]='editSettings' (drillThrough)='drillThrough($event)' (dataBound)='dataBound($event)'>
</ejs-pivotview>
</div>
let cCellColIndex: string;
let cCellRowIndex: string;
onFocusOut(args: any) {
// To maintain the value in pivot grid
let fields: object[] = [];
let row: string[] = args.currentCell.rowHeaders.split(this.pivotObj.engineModule.valueSortSettings.headerDelimiter);
let column: string[] = args.currentCell.columnHeaders.split(this.pivotObj.engineModule.valueSortSettings.headerDelimiter);
for (let j: number = 0; j < row.length; j++) {
let field: object = {};
field[this.pivotObj.dataSourceSettings.rows[j].name] = row[j];
fields.push(field);
}
for (let j: number = 0; j < column.length; j++) {
let field: object = {};
field[this.pivotObj.dataSourceSettings.columns[j].name] = column[j];
fields.push(field);
}
let index: number[] = [];
for (let i: number = 0; i < Pivot_Data.length; i++) {
let value: number = 0;
for (let j: number = 0; j < fields.length; j++) {
if (Pivot_Data[i][Object.keys(fields[j])[0]] &&
String(Pivot_Data[i][Object.keys(fields[j])[0]]) === fields[j][Object.keys(fields[j])[0]]) {
value++;
}
}
if (value === fields.length) {
index.push(i);
}
}
for (let i: number = 0; i < index.length; i++) {
Pivot_Data[index[i]][args.currentCell.actualText] =
Number(args.currentTarget.querySelector('input').value.replace(/[^0-9]+/g, "")) / index.length;
}
if (index.length) {
(this.pivotObj as any).initEngine();
}
this.pivotObj.showWaitingPopup();
cCellColIndex = (parseInt(args.currentTarget.getAttribute('aria-colindex')) + 1).toString();
cCellRowIndex = args.currentTarget.getAttribute('index');
}
dataBound(args): void {
if (cCellColIndex && cCellRowIndex && document.querySelectorAll('td[aria-colIndex="' + cCellColIndex +'"][index="' + cCellRowIndex +'"]')[0])
document.querySelectorAll('td[aria-colIndex="' + cCellColIndex +'"][index="' + cCellRowIndex +'"]')[0].classList.add('e-focused')
}
|