App.component.ts
public onSelect(args: any): void {
if(args.item.text === 'Update'){
this.grid.endEdit();
}
if(args.item.text === 'Edit'){
this.grid.selectRow(0);
this.grid.startEdit();
}
if(args.item.text === 'Delete'){
this.grid.selectRow(0);
this.grid.deleteRow(this.grid.getContent().querySelectorAll('.e-row')[0] as any);
}
} |
App.component.html
<ng-template #toolbarTemplate let-data>
<button ejs-dropdownbutton [items]='items' (select)='onSelect($event)' content='Edit Options'></button>`
</ng-template> |
<ejs-grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
. . . .
</ejs-grid>
<ng-template #template let-data>
<ejs-checkbox label="Checkbox" [indeterminate]="true"></ejs-checkbox>
</ng-template>
|
@ViewChild('template')
public toolbarTemplate: any;
@ViewChild('template2')
public sliderTemplate: any;
public ngOnInit(): void {
this.data = orderDetails;
this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Dialog' };
this.toolbar = ['Add', 'Edit', 'Delete', ‘Search’, {template: this.toolbarTemplate}, {template: this.sliderTemplate}];
. . . . .
}
|
In the above solution against showing dropdown list button in the toolbar of the grid, I can't find any sample code.
Could you please provide a sample where we can show
dropdown list button in the gantt toolbar
you can use below sample code or any other sample code above where using gantt chart.
https://stackblitz.com/edit/angular-ommbgt-81vne4?file=app.component.ts,app.component.html
Hi Mukarram,
The sample has been modified with a custom drop-down button in the toolbar. To achieve this, we have used a custom toolbar item of type button and then rendered the dropdown button using the Created event. For your reference, sample and code snippets are attached. Check the sample and documentation links below for more details.
Code Snippets:
[App.component.ts]
public menuItemsss = [ { text: 'Cut', }, { text: 'Copy', }, { text: 'Paste', }, ]; public Created() { new DropDownButton( { content: 'DropDownButton', items: this.menuItemsss, }, '#dropDownButton' ); } //… this.toolbar = [ 'Add', 'Edit', 'Update', { type: 'Button', text: 'DropDownButton', align: 'Right', template: '<button id="dropDownButton"></button>', }, ];
[App.component.html]
<ejs-gantt #ganttToolbar (created)="Created($event)" > |
Sample: https://stackblitz.com/edit/angular-ommbgt-bkxztu?file=app.component.ts,app.component.html
UG Documentation: https://ej2.syncfusion.com/angular/documentation/gantt/toolbar/#custom-toolbar-items
Regards,
Gopinath M
the dropdownButton and dropdown list options are not in sync, it is moving away on changing screen size or if we open brower console etc. so this option list should stick to button.
Mukarram, using the toggle method, we can close the dropdown button popup for zoom in/out. For your reference, a sample and code snippets are attached. Check the sample and code snippets below for more details.
Code Snippets:
[app.component.ts]
window.addEventListener("resize", function() { var popupElem = document.getElementsByClassName('e-popup-open'); if (popupElem.length != 0) { dropdownBtn.toggle(); } }); |
Sample link: https://stackblitz.com/edit/angular-ommbgt-grbae1?file=app.component.ts