EasyUI Forum

General Category => Bug Report => Topic started by: felixHo on November 13, 2018, 06:35:27 PM



Title: datagrid issue
Post by: felixHo on November 13, 2018, 06:35:27 PM
Please try below code. The datadrid only show one time, next time it doesn't work. Version 1.5.1 has no this issue.
<script>
      function Opentest(){
         InitGrid();
         $('#dialog').dialog('open').dialog('setTitle', 'Test');
      }
      
      function InitGrid(){
         $('#grid').datagrid({
            singleSelect:true,
            collapsible:true,
            //url:'datagrid_data1.json',
            //method:'get',
            columns: [[
               { field: 'itemid', title: 'Item ID' },
               { field: 'productid', title: 'Product' },
               { field: 'listprice', title: 'List Price' },
               { field: 'unitcost', title: 'Unit Cost' },
               { field: 'attr1', title: 'Attribute' },
               { field: 'status', title: 'Status' },
               ]],
            });
            
         $('#grid').datagrid('loadData', { total: 0, rows: [] });
         //GridAppend();
      }
   </script>
</head>
<body>
   <div style="padding:5px 0;">
      <a href="javascript:Opentest();" class="easyui-linkbutton" data-options="iconCls:'icon-add'">Add</a>
   </div>

   <div id="dialog" class="easyui-dialog" style="width: 1060px; padding: 1px; overflow-y:scroll; height:auto;" closed="true" resizable="true" modal="true" data-options="iconCls: 'icon-batchadd', buttons: '#dlg-buttons'">
      <form id="form" method="post" novalidate="novalidate">
         <table id="grid" class="easyui-datagrid" title="Basic DataGrid" style="width:700px;height:250px"></table>
      </form>
   </div>
</body>


Title: Re: datagrid issue
Post by: stworthy on November 14, 2018, 12:24:09 AM
You should initialize the datagrid after opening the dialog.
Code:
$('#dialog').dialog('open').dialog('setTitle', 'Test');
InitGrid();