| import * as React from 'react'; import * as ReactDOM from 'react-dom'; import { ButtonComponent } from '@syncfusion/ej2-react-buttons'; import { GridComponent, Inject, ColumnsDirective, Toolbar, ToolbarItems, ColumnDirective, Filter } from '@syncfusion/ej2-react-grids'; import { data, employeeData } from './datasource'; class App extends React.Component<{}, {}>{ public toolbarOptions: ToolbarItems[] = [{ text: 'Expand All', tooltipText: 'Expand All', prefixIcon: 'e-expand', id: 'expandall' }]; // prefixIcon accepts class name for icon public editOptions: EditSettingsModel = { allowEditing: true, allowAdding: true, allowDeleting: true }; private grid: Grid; public dataBound(){ Object.assign((this.grid.filterModule).filterOperators, {startsWith: 'contains'}); } render(){ return (<div> <GridComponent dataSource={employeeData} editSettings={this.editOptions} toolbar={this.toolbarOptions} gridLines='Both' allowFiltering={true} height={280} ref={g => this.grid = g} dataBound= { this.dataBound.bind(this)}> <ColumnsDirective> <ColumnDirective field='FirstName' headerText='First Name' width='150'></ColumnDirective> <ColumnDirective field='LastName' headerText='Last Name' width='120' textAlign="Right"></ColumnDirective> <ColumnDirective field='Title' headerText='Title' width='150'></ColumnDirective> </ColumnsDirective> <Inject services={[Filter, Toolbar ]} /> </GridComponent></div>) } }; ReactDOM.render(<App />, document.getElementById('grid')); |
| <style> #loader { color: #008cff; height: 40px; left: 45%; position: absolute; top: 45%; width: 30%; } .e-expand::before { content: '\e82e'; //put icon id here which will be available on resource file, attached this } .e-collapse::before { content: '\e834'; } </style> |
|
public editOptions: EditSettingsModel = { allowEditing: true, allowAdding: true, allowDeleting: true };
private grid: Grid;
public rowDataBound(e) {
var command = e.row.querySelector('.e-btn');
if(command){
command.title = "Custom Delete" // customize the tooltip text
}
}
public dataBound(){
Object.assign((this.grid.filterModule).filterOperators, {startsWith: 'contains'});
}
public commands: any = [
{ type: 'Delete', buttonOption: { iconCss: 'e-icons e-delete', cssClass: 'e-flat' } }];
render(){
return (<div>
<GridComponent dataSource={employeeData} editSettings={this.editOptions} toolbar={this.toolbarOptions} gridLines='Both' allowFiltering={true} height={280} ref={g => this.grid = g} dataBound= { this.dataBound.bind(this)} rowDataBound={this.rowDataBound}>
<ColumnsDirective>
<ColumnDirective field='EmployeeID' headerText='ID' width='80' textAlign='Right' isPrimaryKey={true} validationRules={this.validationRule}></ColumnDirective>
<ColumnDirective field='FirstName' headerText='First Name' width='100'></ColumnDirective>
<ColumnDirective headerText='Manage Records' width='50' commands={this.commands}></ColumnDirective>
</ColumnsDirective>
<Inject services={[Filter, Toolbar,Edit,CommandColumn ]} />
</GridComponent></div>)
}
};
ReactDOM.render(<App />, document.getElementById('grid'));
|