EasyUI Forum
May 15, 2024, 03:19:20 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: out of control, the new added row is auto saved evenif the autoSave set false  (Read 4042 times)
Jeffrey AnnSheila
Newbie
*
Posts: 21


View Profile Email
« 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?
Logged
Jeffrey AnnSheila
Newbie
*
Posts: 21


View Profile Email
« Reply #1 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>
« Last Edit: May 31, 2016, 05:55:18 AM by Jeffrey AnnSheila » 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!