Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions samples/grids/tree-grid/data-exporting-indicator/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IgcGridToolbarComponent, IgcTreeGridComponent } from 'igniteui-webcomponents-grids/grids';
import { defineComponents, IgcButtonComponent } from 'igniteui-webcomponents';
import { OrdersTreeData } from './OrdersData';
import { OrdersTreeData, OrdersTreeDataItem } from './OrdersData';
import 'igniteui-webcomponents-grids/grids/combined';
import 'igniteui-webcomponents-grids/grids/themes/light/bootstrap.css';

Expand All @@ -10,15 +10,8 @@ defineComponents(IgcButtonComponent);
export class Sample {

constructor() {
const localData: any[] = [];
for (let i = 0; i < 10000; i += 3) {
for (let c = 0; c < this.ordersTreeData.length; c++) {
localData.push(this.ordersTreeData[c]);
}
}

var treeGrid = document.getElementById('treeGrid') as IgcTreeGridComponent;
treeGrid.data = localData;
treeGrid.data = this.generateData();

var toolbar = document.getElementById('toolbar') as IgcGridToolbarComponent;
var button = document.getElementById('simulate') as IgcButtonComponent;
Expand All @@ -38,6 +31,45 @@ export class Sample {
}
return this._ordersTreeData;
}


generateData() {
const localData: OrdersTreeDataItem[] = [];
for (let i = 1; i < 10000; i += 1) {

const randomId = 1 + Math.floor(Math.random() * 3);
let childRows: OrdersTreeDataItem[] = [];
let childIndex = 0;
for (let c = 0; c < this.ordersTreeData.length; c ++) {
const item = this.ordersTreeData[c];
if (item.ParentID == -1 || !item.ID.toString().startsWith(randomId.toString())) {
continue;
}
childRows.push({
...item,
ID: parseInt(`${i}0${childIndex}`),
ParentID: i,
});
childIndex++;
}

localData.push({
ID: i,
ParentID: -1,
Name: `Oder ${i}`,
Category: '',
Units: childRows.map(row => row.Units).reduce((prev, curr) => prev + curr, 0),
Price: childRows.map(row => row.UnitPrice).reduce((prev, curr) => prev + curr, 0),
UnitPrice: Math.random() * 1000,
OrderDate: '',
Delivered: Math.floor(Math.random()) ? true : false,

});
localData.push(...childRows);
}

return localData;
}
}

new Sample();