I had the same goal. I was able to accomplish it using the code below. I have a step to verify a row is selected else show an alert. My action is to go to a different page to edit/create the record rather than using the built in modal boxes.
function showAlert(title, msg) {
ej.popups.DialogUtility.alert({
title: title,
content: msg,
okButton: { text: "Ok" },
showCloseIcon: true,
closeOnEscape: true,
animationSettings: { effect: 'Zoom' }
});
}
function toolbarClick(args) {
var domain = window.location.origin;
var newURL = "";
if ("1" + this.getSelectedRowIndexes() + "1" !== "11") {
var selectedrowindex = this.getSelectedRowIndexes(); // get the selected row indexes.
var selectedrecords = this.getSelectedRecords(); // get the selected records.
var RowId = this.getSelectedRecords()[0].<fieldIdentity>;
if (args.item.id === 'Edit') {
newURL = "/<path>/Edit/" + RowId;
window.location.replace(domain + newURL);
}
if (args.item.id == 'Add') {
newURL = "/<path>/Create/";
window.location.replace(domain + newURL);
}
if (args.item.id == 'Refresh') {
location.reload('true');
}
}
else {
if (args.item.id == 'Edit') {
showAlert("Warning!", "You must first select a row by clicking on it in order to edit the data.");
}
if (args.item.id == 'Add') {
newURL = "/<path>/Create/";
window.location.replace(domain + newURL);
}
if (args.item.id == 'Refresh') {
location.reload('true');
}
}
}