EasyUI Forum

General Category => Bug Report => Topic started by: Stefan B. on February 11, 2015, 03:57:46 AM



Title: edatagrid - bug with onBeforeSave and autoSave [fixed]
Post by: Stefan B. on February 11, 2015, 03:57:46 AM
We use a table with autoSafe:true and valide something in the event methode onBeforeSave

Code:
ddv.edatagrid({
pagination: true,
singleSelect:true,
autoSave: true,
columns:[[
{fields ...}
]],
onBeforeSave: function(index) {
//check special flags
if(!handleCheckMigrationSuccessfulAndFallbackFlags($(this), index)) {
return false;
}
return true;
}
...
});

The autosave works fine if the result of onBeforeSave is true.

But after the first time onBeforeSave returns false
and changing the row fields so that  onBeforeSave return true
the autosave is not working any more.

What can be here the problem?


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: jarry on February 11, 2015, 04:29:54 PM
What does you function 'handleCheckMigrationSuccessfulAndFallbackFlags' do? Please provide an example to demonstrate your issue.


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: Stefan B. on February 11, 2015, 11:36:32 PM
The method checks something and only return true or false.

We tests something. And the event onBeforeSave is only trigger one time
when autoSave is true and click outside the datagrid!


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: jarry on February 12, 2015, 09:04:00 AM
Please refer to this example https://jsfiddle.net/y0obkqaa/. If your issue continues, try to download the updated edatagrid plugin from http://www.jeasyui.com/extension/edatagrid.php


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: Stefan B. on February 19, 2015, 02:51:30 AM
Hi. I try your exsample. Your exsample code is not working why you use a wrong JQuery version.
I copy the code to my new exsample:
http://jsfiddle.net/sbrandt/0hk1twng/

Whi the new jquery.edatagrid.js it is now working!

But now we have a bigger problem when one alert message should shown in the else block!
Then we have a loop on the event and the application hangs!

Code:
        onBeforeSave: function(index){
            var ed = $(this).edatagrid('getEditor',{index:index,field:'f4'});
            if ((ed.target).is(':checked')){
                //use the alert and the onBeforeSave event is called in a loop when autoSave is active!!!
                //$.messager.alert('error', 'message cannot save why ....' , "warning");
                return false;
            }
        }  

How can we now sho an alert message here?


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: jarry on February 19, 2015, 06:41:39 AM
Please refer to this example http://jsfiddle.net/0hk1twng/4/. If your issue continues, please try to download the newest 'jquery.edatagrid.js' file from http://www.jeasyui.com/extension/edatagrid.php.


Title: Re: edatagrid - bug with onBeforeSave and autoSave
Post by: Stefan B. on February 20, 2015, 05:21:39 AM
With the extension update is the bug now fixed  :D
THX for the support