EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Stefan B. on May 23, 2014, 06:32:53 AM



Title: How can I show a confirm message before saveing a edatagrid row
Post by: Stefan B. on May 23, 2014, 06:32:53 AM
How can I show a confirm message before saveing a edatagrid row and if the result of confirm is false cancel the data row saveing.
The following code is not working while the $.messager.alert() working asynchronous.

Code:
   onBeforeSave: function(rowIndex) {
$.messager.confirm(infoTitleConfirm, confirmEdit, function(confirmResult){
if (confirmResult == true) {
return true;
} else {
        return false;
                }
});


Title: Re: How can I show a confirm message before saveing a edatagrid row
Post by: stworthy on May 23, 2014, 07:30:14 AM
Please try this:
Code:
	onBeforeSave:function(index,row){
var dg = $(this);
var opts = dg.edatagrid('options');
$.messager.confirm('confirm','Are you sure you want to save?', function(r){
if (r){
var onBeforeSave = opts.onBeforeSave;
opts.onBeforeSave = function(){};
dg.edatagrid('saveRow');
opts.onBeforeSave = onBeforeSave;
}
});
return false;
}


Title: Re: How can I show a confirm message before saveing a edatagrid row
Post by: Stefan B. on May 27, 2014, 12:15:51 AM
THX stworthy - that works.

But it would be good to have a default confirm message before saving data in EasyUi. Similarly, the destroy confirm message.
Over a flag like "activateSaveConfirmMsg" the "save confim message" can be activated.


Code:
		destroyMsg:{
norecord:{
title:'Warning',
msg:'No record is selected.'
},
confirm:{
title:'Confirm',
msg:'Are you sure you want to delete?'
}
},