Grid configuration properties allows for only a static text message. The default is
I typically like to include teaser information in case the user isn't paying attention or stray clicked. For example:
Such a message requires Grid _confirmation method to handle a confirmation setting which is a function. The following code modifications does so:
grid.js
removeRow calls _confirmation with model
mypage.js
and in .kendoGrid configuration specify confirmation as a function.
A coder could also template the confirmation text, but only the text because the confirmation dialog raised by _showMessage is the native browser routine window.confirm(text).
A further modification of _confirmation could handle the return type to enable an even more sophisticated custom confirmation() behavior:
string -> use standard kendo prompter with returned text as prompt
false -> cancel the delete action. function raised a custom dialog, or programmatic determination
true -> attempted an unprompted deletion. function raised a custom dialog, or programmatic determination
Enjoy,
Richard
DELETECONFIRM = "Are you sure you want to delete this record?",I typically like to include teaser information in case the user isn't paying attention or stray clicked. For example:
"Are you sure you want to delete Jim Bob's dental records?",Such a message requires Grid _confirmation method to handle a confirmation setting which is a function. The following code modifications does so:
grid.js
removeRow calls _confirmation with model
removeRow: function(row) { var that = this, model, mode; row = $(row); //RAD model = that._modelForContainer(row); // RAD // if (!that._confirmation()) { if (!that._confirmation(model)) { // RAD pass model unconditionally. callee will decide what to do with it return; } row.hide(); // row = $(row).hide(); // RAD // model = that._modelForContainer(row); // RAD if (model && !that.trigger(REMOVE, { row: row, model: model })) { that.dataSource.remove(model); mode = that._editMode(); if (mode === "inline" || mode === "popup") { that.dataSource.sync(); } } },if confirmation is a function pass the model to it
_confirmation: function(model) { // RAD var that = this, editable = that.options.editable, confirmation = editable === true || typeof editable === STRING ? DELETECONFIRM : isFunction(editable.confirmation) ? editable.confirmation(model) : editable.confirmation; return confirmation !== false && confirmation != null ? that._showMessage(confirmation) : true;},mypage.js
and in .kendoGrid configuration specify confirmation as a function.
editable: { mode:"popup", confirmation: function(model) { return 'Are you sure you want to delete the '+model.rectype+' record of '+model.name+'?' }},A coder could also template the confirmation text, but only the text because the confirmation dialog raised by _showMessage is the native browser routine window.confirm(text).
A further modification of _confirmation could handle the return type to enable an even more sophisticated custom confirmation() behavior:
string -> use standard kendo prompter with returned text as prompt
false -> cancel the delete action. function raised a custom dialog, or programmatic determination
true -> attempted an unprompted deletion. function raised a custom dialog, or programmatic determination
Richard