Data "lost" on Grid

Dear members,

I use the add-on grid for my application. I add searching and sorting features on the grid. But sometimes the data not appear whereas the data is exist. Any suggestions to resolve this ?

Unfortunately we cannot reproduce this issue locally. Please provide us any kind of sample or a demo link where we can reproduce an error.

Dear sematik,

Here is the link that linked to the grid component.

<link rel="stylesheet" type="text/css" href="<?php echo WEB_ROOT;?>library//dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="<?php echo WEB_ROOT;?>library//dhtmlxSuite/dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/sources/ext/dhtmlxgrid_start.js"></script>	
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/sources/ext/dhtmlxgrid_pgn.js"></script>	
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/sources/ext/dhtmlxgrid_filter.js"></script>			
<script src="<?php echo WEB_ROOT?>library//dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>	

I put those line on template.php

And here is the grid

<?php if (!defined('WEB_ROOT')) { exit; } require_once '../class/site.php'; require_once '../class/user.php'; require_once '../class/company.php'; require_once '../class/vessel.php'; $userConfig = getUserConfig($_SESSION['login']); $id = $userConfig['id']; $site = $userConfig['site']; $level = $userConfig['level']; $nama = $userConfig['nama']; $type = 'OFF'; $user = new user($id); $level = $user->getModulLevel($type); $search = (isset($_GET['key']) && $_GET['key'] != '') ? $_GET['key'] : ''; if ($search!='') $whereClause="WHERE (doc.type='OFF') AND (doc.off='1') AND (doc.kode like '%$search%' OR doc.namaSupplier like '%$search%' OR doc.namaVessel like '%$search%' OR doc.remarks like '%$search%' ) AND (doc.pic=$id) "; else $whereClause="WHERE (doc.type='OFF') AND (doc.off='1') AND (doc.pic='$id') "; if ($level=='root') { if ($search!='') $whereClause="WHERE (doc.type='OFF') AND (doc.kode like '%$search%' OR doc.namaVessel like '%$search%' OR doc.namaSupplier like '%$search%' OR doc.remarks like '%$search%' ) "; else $whereClause="WHERE (doc.type='OFF') "; } if ($level=='admin') { if ($search!='') $whereClause="WHERE (doc.type='OFF') AND (doc.kode like '%$search%' OR doc.namaVessel like '%$search%' OR doc.namaSupplier like '%$search%' OR doc.remarks like '%$search%' ) AND ( (doc.kodeSiteAsal='$site') or (doc.kodeSiteTujuan='$site' ) ) "; else $whereClause="WHERE (doc.type='OFF') AND ( (doc.kodeSiteAsal='$site') or (doc.kodeSiteTujuan='$site' ) ) "; } $sql = "SELECT doc.kode, doc.type, doc.kodeCompany, doc.attachment, doc.kodeSiteAsal, doc.kodeSiteTujuan, doc.kodeSupplier, doc.kodeVessel, doc.namaVessel, date_format(doc.tgl,'%d-%m-%Y') as tgl, doc.remarks, doc.adv, doc.status, doc.proses, doc.isCancel, doc.pic, if(isnull(vessel.id),kodeVessel,vessel.id) as idVessel, company.id as idCompany, date_format(doc.estPaymentDate,'%d-%m-%Y') as estPaymentDate, doc.pic, doc.ap, doc.flag, doc.holder FROM doc LEFT JOIN company ON doc.kodeCompany=company.kode LEFT JOIN vessel ON doc.kodeVessel=vessel.kode $whereClause ORDER BY doc.tgl DESC"; $rowsPerPage = 50; $result = dbQuery(getPagingQuery($sql, $rowsPerPage)); $pagingLink = getPagingLink($sql, $rowsPerPage); $error = (isset($_GET['error']) && $_GET['error'] != '') ? $_GET['error'] : ''; ?>
Search :
<?php
if (dbNumRows($result) > 0) 
{
	$i = 0;	
	while($row = dbFetchAssoc($result)) 
	{
		extract($row);		
		if ($i%2) 
		{
			$class = 'row1';
		}	 
		else 
		{
			$class = 'row2';
		}		
	$i += 1;

?>

<?php } } ?>
PO No. Supplier Vessel Remarks PO Date Payment Date Adv Total Creator Holder Status View Update
<?php $comp = new company($kodeCompany); $docCode = $comp->getDocCode();
		$v			= new vessel($kodeVessel);
		$callSign	= $v->getCallSign();		
		
		if ($docCode=='id')			
		{
			echo $idCompany.$idVessel.'-'.$kode; 
		}
		else
		if ($docCode=='cs')			
		{
			echo $callSign.$kode; 
		}
	?>
<?php $supplier = new supplier($kodeSupplier); echo $supplier->getNama(); ?> <?php $vessel = new vessel($kodeVessel); echo $vessel->getNama(); ?> <?php echo nl2br($remarks); ?> <?php echo $tgl; ?> <?php echo $estPaymentDate;?> <?php if ($adv=='1') echo 'Yes'; else echo 'No'; ?> <?php $sql2 = "SELECT mataUang, sum( total ) as total FROM ( SELECT mataUang, CASE discType WHEN 'Direct Pricing' THEN ((harga*qty)-discAmount) * ((100+pajak)/100) WHEN 'Percentage' THEN (harga*qty)*((100-discAmount)/100) * ((100+pajak)/100) ELSE (harga*qty) * ((100+pajak)/100) END AS total FROM detaildoc WHERE kodeDoc='$kode' AND type='$type' AND kodeCompany='$kodeCompany' AND kodeVessel='$kodeVessel' ) as t GROUP BY mataUang "; $result2 = dbQuery($sql2); while($row2 = dbFetchArray($result2)) { list($mataUang, $total) = $row2; echo $mataUang.' '.number_format($total,2); echo '
'; } ?>
<?php $user = new user($pic); echo $user->getNama(); ?> <?php $user = new user($holder); echo $user->getNama(); ?> <?php echo $flag; ?> View Update

Sometime the data is exist but sometime the data is lost. So, I add a text box for enhanced the query. And here is the javascript for the search box

function show()
{
window.location.href = ‘index.php?view=list’;
}

function search()
{
with (window.document.frmSearch)
{
window.location.href = ‘index.php?view=list&key=’+txtKey.value;
}
}

So, any suggestion ?

To initialize grid from HTML table you may use 2 approaches:

  1. automatic initialization using class=“dhtmlxGrid”
    or
  2. initialization with API using dhtmlXGridFromTable

In your code you are are mixing those 2 approaches:

<table id="table" class="dhtmlxGrid" gridWidth="900px" gridHeight="600px" multiline="true" border="1" unevenrow="row1" evenrow="row2" > .... var grid = dhtmlXGridFromTable("table");

You should choose which one you will use. More information is avialable here docs.dhtmlx.com/doku.php?id=dhtm … _from_html

I’d change my code. I remove the class property on the table tag. I’ll look if the data still ‘lost’ on the grid or not. Thank you for the correction :wink: