Title: out of control, the new added row is auto saved evenif the autoSave set false Post by: Jeffrey AnnSheila on May 29, 2016, 07:22:56 PM I am confused by a problem that is in an editable datagrid of edatagrid, after a new row is added, if you click the other row without clicking the save button in the toolbar instead, the ajax code still posts the editted data of the new added row with a param/value pair of "isNewRecord=true" .I have set the autoSave property to false, but that doesn't work. i don't know why. How to do it?
Title: Re: out of control, the new added row is auto saved evenif the autoSave set false Post by: Jeffrey AnnSheila on May 31, 2016, 05:47:50 AM well,i try to work it out by jscode like below:
<div id="toolbarCase" hidden="hidden"> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addRow')">new</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyRow')">delete</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="save();">save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">cancel</a> </div> <table id="dgCase"></table> <script type="text/javascript"> var conf = { options:{ ... ... }, columns:[[ ... ...]] }; var commit=false; var save=function(){ commit=true; $('#dg').edatagrid('saveRow'); } $(function(){ $('#dg').edatagrid({ ... ... autoSave:false, onSave:function(index,row){ commit=false; }, onBeforeSave:function(index){ if(commit==false){ return false; } } }).datagrid('subgrid', conf); </script> |