EasyUI Forum
May 17, 2024, 11:26:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How can I show a confirm message before saveing a edatagrid row  (Read 6037 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« 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;
                }
});
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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;
}
Logged
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« Reply #2 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?'
}
},

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!