EasyUI Forum
September 16, 2025, 09:25:02 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: Data is not updated in datagrid  (Read 7679 times)
smartec
Newbie
*
Posts: 4


View Profile
« on: January 10, 2016, 04:02:02 AM »

Hi there,

I have problems using easyui. I encountered that the data is not consistent (i.e. the datagrid can show outdated data)

For example, I have data Item A with qty of 10pcs, after that I performed some actions on the Item A, and change the qty to 5pcs. Sometimes the datagrid shows the qty of Item A as 10 again even though the database already shows that Item A qty is 5 pcs. This thing happens when I refresh the datagrid using my "refresh" function. Any idea on what is going on?

Here is my code for the datagrid and the reload function. The easyui version that I used is 1.3.6

My datagrid function:
<div data-options="region:'center',border:false,iconCls:'icon-ok'">
       
      <!-- gaya table baru di grid -->
      
      <table id="grid"
           title="" iconCls="icon-edit"
            singleSelect="true" rowNumbers="true"
            pageSize="50"
            fitColumns="true" remoteSort="false"
            url="<?=base_url($menu_link.'/ajax')?>"
            style="width:auto;height:560px"
            data-options = "border:false,view:scrollview,autoRowheight:false"
        >
   
public function ajax(){
      $page   = ($this->input->post('page')) ? intval($this->input->post('page')) : 1;
      $rows   = ($this->input->post('rows')) ? intval($this->input->post('rows')) : 150;
      
      $hasil = array();
   
                $count_data = $this->db->count_all_results('at_purchaserequisition');
      
      $offset    = $count_data - ($rows * $page);
      if($offset > 0){
         $rows = $rows;
      }
      else{
         $rows = $count_data - ($rows*($page-1));
      }
      /*========================end=======================================*/
      $result = $this->m_purchase_requisition->get_all();
      
      for($i=0; $i<=($rows-1); $i++){
         // kalau master ambil dari get_status_master(), kalau transaksi get_status()
         $TransStatus = get_status($result[$i]->TransStatus);

            $hasil[] = array(
            'BranchName'       =>   $result[$i]->BranchName,
            'DepartmentName'    =>   $result[$i]->DepartmentName,
            'PReqNumber'       =>   $result[$i]->PReqNumber,
            'PReqDate'          =>   $result[$i]->PReqDate,
            'PReqDesc'          =>   $result[$i]->PReqDesc,
            'CreatedBy'       =>   $result[$i]->CreatedBy,
            'Status'          =>   $TransStatus
         );
      }
      
      if(empty($hasil)){
         $emptyVar = array();
         echo json_encode($emptyVar);
      }
      else{
         $result = array();
         $result['total'] = $count_data;
         $result['rows'] = $hasil;
         echo json_encode($result);
      }   
    }


My Reload function:
<a href="#" class="easyui-linkbutton" id="refresh-linkbutton" data-options="plain:true,iconCls:'icon-reload'" onclick="$('#grid').datagrid('reload')">Refresh</a>


Thanks in advance,

Prawira       
Logged
jarry
Administrator
Hero Member
*****
Posts: 2298


View Profile Email
« Reply #1 on: January 10, 2016, 05:23:46 PM »

Please open the browser's develop tool and switch to the 'Network' tab, Is the ajax request sent to your server when calling 'reload' method? You need to use the newest 'datagrid-scrollview.js' file that can be downloaded from http://www.jeasyui.com/extension/datagridview.php
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!