I am developing an application using Easyui Grid/Subgid Panel. Screen shot is attached with. Here data of the main grid is populated after selecting year and section. It is loading fine. Now when I expand row of this grid from last row to first backwards, everytime subpanel opens and data is loaded correctly, but if I expand rows from first to last that is in forward direction only first panel loads data, expanding rest of the rows do not load data in subpanel.
In this connection I am attaching some code snippet for the application.
Javascript for the main grid (#dg1)
$('#dg1').datagrid({
view: detailview,
detailFormatter:function(index,row){
return '<div class="ddv" style="padding:2px"></div>';
},
onExpandRow: function(index,row){
var yr = $('#year').combobox('getValue');
var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
ddv.panel({
border:false,
cache:false,
href:'exeneed.getDetails.php?yr='+yr+'&tno='+row.tno,
onLoad:function(){
$('#dg1').datagrid('fixDetailRowHeight',index);
}
});
$('#dg1').datagrid('fixDetailRowHeight',index);
}
});
Now here is details of SubPanel / exeneed.getDetails.php :
<?php
include 'config.php';
include 'lock.php';
$tno = intval($_REQUEST['tno']);
$yr = intval($_REQUEST['yr']);
?>
<div style="width:918px; border: 1px solid #cacaff; padding:10px 10px 10px 50px;">
<label>Need-Based Module:</label>
<input id="progname" name="progname" class="easyui-combobox"
style="width:500px;"
data-options="valueField:'Id', textField:'progname', url:'getExeProg.php', required:true " />
<a href="#" class="easyui-linkbutton" iconCls="icon-add" onclick="addNeed()">Add</a>
<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="delNeed()">Remove</a>
</div>
<table id="dg3" class="easyui-datagrid" style="width:980px;height:200px; float:left;"
rownumbers="true" singleSelect="true" >
</table>
<script type="text/javascript">
$(function(){
var yr = $('#year').combobox('getValue');
var s = $('#dg1').datagrid('getSelected');
var t = <?php echo $tno; ?>;
$('#dg3').datagrid({
url:'exeNeedInd.php?tno='+t+'&yr='+yr,
columns:[[
{field:'Id',title:'',width:0,align:'right',hidden:true},
{field:'trgcode',title:'ProgCode',width:80,align:'center'},
{field:'mapprog',title:'Training Module',width:500},
{field:'status',title:'Status',width:50,align:'center'},
{field:'trgdate',title:'Plan Date',width:80,align:'center'},
{field:'actdate',title:'Act Date',width:80,align:'center'},
{field:'updcause',title:'Remarks',width:140}
]]
});
});
</script>
Now In this panel Subgrid is loaded from another PHP code exeNeedInd.php, this is given below:
<?php
include 'config.php';
include 'lock.php';
$tno = intval($_REQUEST['tno']);
$yr = intval($_REQUEST['yr']);
$sql2 = "select * from empmst where tno=$tno";
$rs2 = mysql_query($sql2) or die('not found!');
$row2 = mysql_fetch_object($rs2);
$grade = $row2->grade;
$descode = $row2->descode;
$level = substr(trim($grade),1,1);
$sql3 = "select * from priority where year=$yr and level1<=$level and level2>=$level ";
//echo $sql3 . "<br>";
$rs3 = mysql_query($sql3) or die('not found!');
if($rs2){
while($row3 = mysql_fetch_object($rs3)){
$sql5 = "select * from skrating where year=$yr and tno=$tno and trgcode='$row3->trgcode'";
//echo $sql5 . "<br>";
$rs5 = mysql_query($sql5) or die('not found!');
if(mysql_num_rows($rs5)<=0){
$sql4 = "insert into skrating (tno, fileno, secode, secode2, year, skname, sktype, mapprog, trgcode, status, tno2, lastupdt) values ($tno,$row2->fileno,$row2->secode,$row2->secode2,$yr,'', '', '$row3->mapprog', '$row3->trgcode', $row3->status ,'AUTO', now())";
$rs4 = @mysql_query($sql4);
//echo $sql4 . "<br>";
}
}
}
$sql = "select * from skrating where year=$yr and tno=$tno order by mapprog";
$rs = mysql_query($sql) or die('not found!');
if ($rs){
$items = array();
while($row = mysql_fetch_object($rs)){
array_push($items, $row);
}
echo json_encode($items);
}
?>
I have checked this PHP file by passing year and Tno parameter individually, moreover I have checked database, skrating table is populating correctly, although data is not loaded if I expand from top to bottom rows, but underlying data is there in table. Same data will be displayed if I expand from bottom to top rows one after another.
I cannot understand what is happening and feeling helplessness. So please anybody help me.