<ejs-grid [dataSource]='data' height='315' gridLines= ‘Horizontal’ >
|
import { Component, OnInit,ViewChild } from '@angular/core';
import { data } from './datasource';
import {GridComponent} from '@syncfusion/ej2-angular-grids';
@Component({
selector: 'app-container',
template: `<ejs-grid #grid [dataSource]='data' gridLines= "Horizontal" (dataBound)="dataBound($event)" [allowSorting]='true' height='315px'>
-------
</ejs-grid>`
})
export class AppComponent implements OnInit {
public data: Object[];
@ViewChild('grid')
public grid: GridComponent;
ngOnInit(): void {
this.data = data;
}
dataBound(e){
for (var i = 0; i < this.grid.getHeaderTable().querySelectorAll('.e-headercell').length; i++) {
var margin = this.grid.getHeaderTable().querySelectorAll('.e-headercell')[i].offsetWidth - (42+(this.grid.getHeaderTable().querySelectorAll('.e-headertext')[i].offsetWidth ) + 10); // 42 - headerText padding & 10 is used for adjustment purpose
this.grid.getHeaderTable().querySelectorAll('.e-sortfilterdiv')[i].style.marginRight = margin + "px";
}
}
}
|