EasyUI Forum
September 16, 2025, 11:34:16 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  General Category / EasyUI for jQuery / Data is not updated in datagrid 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       
2  General Category / EasyUI for jQuery / Re: Need Help in Datagrid Virtual Scrolling on: September 07, 2015, 10:05:18 PM
Hi there,

Any help for the problem? The problem that I am having at the moment is that the $page and $rows did not give me the updated value when I have scrolled enough to the page size limit. After I observe my code, the $page and $rows always give the same value.

Many Thanks

Regards,

Prawira
3  General Category / EasyUI for jQuery / Re: Need Help in Datagrid Virtual Scrolling on: September 06, 2015, 09:21:59 PM
Hi Jarry,

I have modified my code in the model into the following

view:
        <table id="tt" style="width:700px;height:300px"
            title="DataGrid - VirtualScrollView"
            data-options="view:scrollview,rownumbers:true,singleSelect:true,
                url:'getdata.php',autoRowHeight:false,pageSize:150">
        <thead>
            <tr>
                <th field="ItemCode" width="80">Item Code</th>
                <th field="ItemDesc" width="100">Item Desc</th>
                <th field="unit" width="80">Unit</th>
            </tr>
        </thead>
    </table>

controller:
getdata.php

    $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 150;
   
    $offset = ($page-1)*$rows;

   
    $items = array();
    $result = $this->m_items->join_all($offset, $rows);
   
    foreach($result as $row){
    $items[] = array(
           'ItemCode' => $row->ItemCode,
           'ItemDesc' => $row->ItemDesc,
           'unit' => $row->unit
       );
    }
    $output = array();
    $output['total'] = 8000;
    $output['rows'] = $items;
    echo json_encode($output);

model:
   
  function join_all($offset, $rows){
 
  $this->db->select('am_item.ItemCode, am_item.ItemDesc, am_item.unit');
  $this->db->from($this->table);
  $this->db->limit($rows, $offset);
  return $result;
 }

After I have modified my code as above, the query only returns the first 150 rows from the database. It seems that the $page and $rows from the scrollview does not get parse into the controller. Any one can point out what I have done wrong in the coding?

Regards,

Prawira
4  General Category / EasyUI for jQuery / Need Help in Datagrid Virtual Scrolling on: September 06, 2015, 05:34:50 AM
Hi there,

I have a problem of slow rendering into datagrid. I have approximately 20.000 data to be shown in data grid. I would like to show the data 150 rows at a time, and when I go to 151 rows, it will load the data from the database again. I have taken look in example in datagrid virtual scrolling and I believe this will help me. But, when I tried the virtual scrolling, I have a problem. The datagrid will load all 20.000 data first and then display 150 rows into the grid. If it will still load all the data, the performance of the grid is more less the same. Anyone can point out the problem that I am having?

Here is the following code.

view:
        <table id="tt" style="width:700px;height:300px"
            title="DataGrid - VirtualScrollView"
            data-options="view:scrollview,rownumbers:true,singleSelect:true,
                url:'getdata.php',autoRowHeight:false,pageSize:150">
        <thead>
            <tr>
                <th field="ItemCode" width="80">Item Code</th>
                <th field="ItemDesc" width="100">Item Desc</th>
                <th field="unit" width="80">Unit</th>
            </tr>
        </thead>
    </table>

controller:
getdata.php

    $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 150;
   
   
    $items = array();
    $result = $this->m_items->join_all();
   
    foreach($result as $row){
    $items[] = array(
           'ItemCode' => $row->ItemCode,
           'ItemDesc' => $row->ItemDesc,
           'unit' => $row->unit
       );
    }
    $output = array();
    $output['total'] = 8000;
    $output['rows'] = $items;
    echo json_encode($output);

Many Thanks before hand,

Regards,

Prawira
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!