EasyUI Forum
May 08, 2024, 08:43:11 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: Is it a bug ?  (Read 8208 times)
Jeffrey AnnSheila
Newbie
*
Posts: 21


View Profile Email
« on: June 22, 2016, 03:36:30 AM »

Hi, i find a problem in my codes, and can't fix it for nealy a week longer, and have to report it here.
I have an editable datagrid, which has an nested subgrid. After I delete all rows of the main grid , then i want to add a new first row again,  but the new row doesn't appear (it only flashes then disappears.) until i  click "AddNew" button of toolbar  the second time.  In order to demo this problem , I modify my codes like below, and ommit the server side codes of CRUD. You have to add the CRUD in your environment if you want to observe the odd problem. If I delete the codes section 'subgrid : {......}' , the problem will disappear, but another problem appears: the new added row has a row number of -9 not 1.

<table id="dg"></table>
<script type="text/javascript">
   var conf = {
      options : {
         rownumbers : true,
         striped : true,
         fitColumns : false,
         nowrap : false,
         fixed : true,
         idField : 'id',
         pagination : true,
         singleSelect : false,
         autoSave : false,
         url : "/getData",
         saveUrl : "/saveData",
         destroyUrl : "/deleteData",
         updateUrl : "/updateData",
         edatagrid : true,
         autoUpdateDetail : false,
         toolbar : [ {
            iconCls : 'icon-add',
            text : 'AddNew',
            handler : function() {

               $(this).datagrid('getSelfGrid').edatagrid('addRow');

            }
         }, {
            iconCls : 'icon-remove',
            text : 'Delete',
            handler : function() {
               $(this).datagrid('getSelfGrid').edatagrid('destroyRow');
            }
         }, {
            iconCls : 'icon-save',
            text : 'Save',
            handler : function() {
               $(this).datagrid('getSelfGrid').edatagrid('saveRow');
            }
         }, {
            iconCls : 'icon-undo',
            text : 'Cancel',
            handler : function() {
               $(this).datagrid('getSelfGrid').edatagrid('cancelRow');
            }
         } ],
         onSuccess : function(index, row) {
            $(this).datagrid('reload');

         },
         columns : [ [ {
            field : 'id',
            title : 'ID',
            width : 100,
            hidden : true
         }, {
            field : 'name',
            title : 'Name',
            width : 200,
            editor : {
               type : 'textbox'
            }
         }, {
            field : 'number',
            title : 'Number',
            width : 200,
            editor : {
               type : 'textbox'
            }
         } ] ]
      },
      subgrid : {
         options : {
            fitColumns : true,
            foreignField : 'id',
            columns : [ [ {
               field : 'orderdate',
               title : 'Order Date',
               width : 200
            }, {
               field : 'shippeddate',
               title : 'Shipped Date',
               width : 200
            }, {
               field : 'freight',
               title : 'Freight',
               width : 200
            } ] ],
            data : [ {
               orderdate : '08/23/2012',
               shippeddate : '12/25/2012',
               freight : 9734
            }, {
               orderdate : '08/23/2012',
               shippeddate : '12/25/2012',
               freight : 9734
            }, {
               orderdate : '08/23/2012',
               shippeddate : '12/25/2012',
               freight : 9734
            } ]
         }

      }
   };

   $(function() {
      $('#dg').edatagrid({
         title : 'xxxxx',
         width : '100%',
         height : '100%'
      }).datagrid('subgrid', conf);
   });
</script>
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 22, 2016, 06:43:14 PM »

Please look at this example http://code.reloado.com/ufasec3/edit#preview. It works fine.
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!