EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: anugrast on December 18, 2016, 09:03:07 PM



Title: Treegrid with filter
Post by: anugrast on December 18, 2016, 09:03:07 PM
Dear all...

I've made treefrid with filter facility like this:

HTML:
Code:
<table id="tgKALAKD" class="easyui-treegrid"	
data-options="
fit:true,
url:'_modul/mod_kalakd/aksi_kalakd.php?act=listKALAKD',
rownumbers: true,
idField: 'kalid',
treeField: 'nama',
onBeforeLoad: function(row,param){
if (!row) { // load top level rows
param.id = 0; // set id=0, indicate to load new page rows
}
}
"
>

PHP:
Code:
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

$where="pParent=".$id;
$result = array();
if ($id == 0){
$qry = "SELECT * FROM uj_akad_kalender WHERE ".$where;
$res = $conDB->query($qry);
$result["total"] = $res->num_rows;

$qry = "SELECT t2.*, (SELECT COUNT(*) FROM uj_akad_kalender AS t1 WHERE t1.pParent = t2.kalid) AS count_parents FROM uj_akad_kalender AS t2 ";
$qry.= "where ".$where;
$res = $conDB->query($qry);
$items = array();
while($row = $res->fetch_assoc()){
if($row['count_parents']>0) {
$row['state']='closed';
} else {
$row['state']='open';
}
if (!is_null($row[tgl_awal])) {
$nyatgl=strtotime($row[tgl_awal]); $row[tgl_awal]=date("d-m-Y",$nyatgl);
} else { $row[tgl_awal]=""; }
if (!is_null($row[tgl_akhir])) {
$nyatgl=strtotime($row[tgl_akhir]); $row[tgl_akhir]=date("d-m-Y",$nyatgl);
} else { $row[tgl_akhir]=""; }
$row['caption']=trim($row['nama']." ".$row['ketambah']);
array_push($items, $row);
}
$result["rows"] = $items;
} else {
$qry = "SELECT t2.*, (SELECT COUNT(*) FROM uj_akad_kalender AS t1 WHERE t1.pParent = t2.kalid) AS count_parents FROM uj_akad_kalender AS t2 ";
$qry.= "where ".$where;
$res = $conDB->query($qry);
$items = array();
while($row = $res->fetch_assoc()){
if($row['count_parents']>0) {
$row['state']='closed';
} else {
$row['state']='open';
}
if (!is_null($row[tgl_awal])) {
$nyatgl=strtotime($row[tgl_awal]); $row[tgl_awal]=date("d-m-Y",$nyatgl);
} else { $row[tgl_awal]=""; }
if (!is_null($row[tgl_akhir])) {
$nyatgl=strtotime($row[tgl_akhir]); $row[tgl_akhir]=date("d-m-Y",$nyatgl);
} else { $row[tgl_akhir]=""; }
$row['caption']=trim($row['nama']." ".$row['ketambah']);
array_push($result, $row);
}
}
echo json_encode($result);

How to bring up the child, including the parent when the filter without having to expand it first... because the parent will appear when it has been in expand.

Here is a screenshot happened:
1. When first run (f-1.jpg)
2. Filter before expand (f-2.jpg)
3. Filter when it has expand (f-3.jpg)
4. I want a result like this (f-4.jpg)

Please help me...




Title: Re: Treegrid with filter
Post by: raghav94 on July 12, 2017, 02:03:36 AM
Did you find a solution to this?