<ejs-grid [dataSource]='data' allowPaging='true' [pageSettings]='pageSettings' [editSettings]='editSettings' (actionComplete)='actionComplete($event)' [toolbar]='toolbar'>
<e-columns>
. . . . . .
</e-columns>
</ejs-grid>
|
actionComplete(args){
if (args.requestType === 'add' || args.requestType === 'beginEdit') {
let button = document.createElement('button');
button.setAttribute('class', 'e-control e-btn e-lib e-flat');
button.setAttribute('cssClass', 'e-flat');
button.innerHTML = 'Copy';
args.dialog.element.querySelector('.e-footer-content').append(button);
button.addEventListener('click', function (e) {
alert("custom button") // you customize as per your need
})
}
}
|
actionComplete(args) {
if (args.requestType === 'add' || args.requestType === 'beginEdit') {
var button = document.createElement('button');
button.setAttribute('class', 'e-control e-btn e-lib e-flat');
button.setAttribute('cssClass', 'e-flat');
button.innerHTML = 'Copy';
button.innerHTML = 'Copy';
button.type="button"; // need to apply type as button to prevent page reload
// insert the button before the ship country field
#gridShipCountry' => grid id+ field name
args.dialog.element.getElementsByTagName('tbody')[0].insertBefore(button, args.dialog.element.querySelector('#gridShipCountry').closest('tr'))
button.addEventListener('click', function (e) {
alert("custom button") // you can do as per your requirement
})
}
}
|
actionComplete(args) {
if (args.requestType === 'add' || args.requestType === 'beginEdit') {
. . . . .
button.addEventListener('click', function (e) {
// get dropdown instance and assign ShipCountry value to dataSource and value property of country dropdown
dialog.element.querySelector('#gridCountry').ej2_instances[0].dataSource = [{ 'Country': dialog.element.querySelector('#gridShipCountry').value }];
dialog.element.querySelector('#gridCountry').ej2_instances[0].value = dialog.element.querySelector('#gridShipCountry').value;
}.bind(this))
}
}
|