EasyUI Forum
April 26, 2024, 04:29:02 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: How to empty / clear all rows in easyUI datagrid? I mean a real 'clearing'  (Read 22930 times)
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« on: August 29, 2014, 04:05:46 AM »

How to remove all data in a datagrid?

i know before another way to clear a datagrid is using

        
Code:
$('#cc').datagrid('loadData', []);  
or
        
Code:
$('#cc').datagrid('loadData', {"total":0,"rows":[]});

or
Code:
var rows = $('#cc').datagrid('getSelections');  // get all selected rows
for(var i=0; i<rows.length; i++){
var index = $('#cc').datagrid('getRowIndex',rows[i].id);  // get the row index
$('#cc').datagrid('deleteRow',index);
}

....why don't we just call  
Code:
$('#cc').datagrid('clear') 
just like the combogrid???

and somehow ive just found a bug...

if you call this script
Code:
$('#cc').datagrid('loadData', []);  
it will reload the current datagrid remotely and then populated with the local empty data..
just look at pic below, the datagrid load data remotely then localy after i fired the $('#cc').datagrid('loadData', [])


i need explanation..

thanks in advance.
« Last Edit: May 02, 2017, 09:42:42 PM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 29, 2014, 06:09:52 AM »

Calling the code $('#cc').datagrid('loadData', []); just clear the datagrid data. This does not make request to the remote server. If your issue continues, please try to download the patch from http://www.jeasyui.com/download/downloads/jquery-easyui-1.4-patch.zip.
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: September 01, 2014, 12:17:10 AM »

i'am using jeasyui 1.4 + your patch...and the problem still unsolved..the datagrid populates again from server..i just want to clear it.,,

here my program listing...
Code:
<a href="#" onClick="emptyMe();">Clear</a>
<table
                id="table_program"
                class="easyui-datagrid"
                data-options="
                    url:'bams/admin/program/list_program',
                    title:false
                ">
                <thead>
                <tr>
                     <th data-options="field:'PROGRAM_ID'" sortable="true">ID</th>
                     <th data-options="field:'PROGRAM_NAME'" sortable="true">Program Name</th>
                </tr>
                </thead>
            </table>

Code:
<script>
function emptyMe(){
        $('#table_program').datagrid('loadData', []);
        return false;
}
</script>

here the pic that shows the $('#table_program').datagrid('loadData', []); fires the datagrid to reload data from server(remote)..

thanks
« Last Edit: September 01, 2014, 12:30:56 AM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
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!