last day (14 days later) » 

08:54
1
Q: Create Dynamic tree with hide and unhide the child

m7mdI'm using a code in php mysql to create a dynamic tree base on mysql This tree is dynamic can change every time base on mysql my question is: How to add + - hide unhide in this tree view ??!! when i click + on the parent the child appear and when i click on - the child disappear and the same...

Can you pls update question with output you of above php code? So we can test it to do so
@GopalJoshi please check above i put the output of html from the browser with an image how it's look and this output is dynamic base on mysql it will be changed
@GopalJoshi any help please!!?
Check here i have updated your html and js code jsfiddle.net/gopaljoshi73/k3bhyeqz/1. please update php code for the same
@GopalJoshi i will test it and reply
@GopalJoshi i need to be + - because i have another idea when i click on the name of folder how can updated ?!
@GopalJoshi i have change it to an arrow icon but it's only work for the root i can't use it for the folder who have child how can i use it ??
can you share your code on jsfiddle pls
08:54
@GopalJoshi the php one ?
hi
no just html
my problem is how to put it with the php code
to appear only on the folder who have child
and when i click the child appear
ok i understood you problem
08:58
ok
can you help me in that ?!
yes for sure
i am reviewing your php code right now
ok thank you
you need to add one field having name 'is_parent' in table `tbl_folders`. If folder have any child folders than there should be true flag in this field and if folder has not any sub folders than false flag should be there.
Eg. IT folder should have true flag and HR folder's record should have false flag
you can check 'is_parent' record if either true or false when rendering treeview. If flg is true than you need to add class="parentCls" data-id = "3" in <a> tag.
ok than know i should add another field name is_parent in database
this will be int 0 1
like this ?
yes
right
09:06
ok 1 min please
i do what you say know i have a field name is_parent all have 0 and it have is_parent 1
what is the second step
you can check 'is_parent' record if either true or false when rendering treeview. If flag is 1 than you need to add "class="parentCls" data-id = "3"" in "<a>" tag.
you mean here
function buildTreeHTML(&$list, $parentID = 0) {
$isBranch = false;
foreach ($list as $index => $element) {
if($list[$index]['parent_id'] != $parentID) continue;
if(!$isBranch) {
echo '<ul class="main-ul child-cls-0">';
$isBranch = true;
}
echo"<div class='edit'><a href='edit.php?id={$list[$index]['db_id']}'><img src='../img/edit.png'></a></div>";
echo"<div class='delete'><a class='del'href='edit.php?delete={$list[$index]['db_id']}&parent_id={$list[$index]['parent_id']}' data-confirm='Are you sure to delete this item?'><img src='../img/delete.png'></a></div>";
ok now i have this variable $is_parent=$currentFolderArray['is_parent'];
Something like
echo "<li><label><a class='".($list[$index]['is_parent'] == 1 ? 'parentCls' : '')."' data-id='".($list[$index]['is_parent'] == 1 ? $list[$index]['db_id'] : '')."' href='dms.php?parentID={$list[$index]['db_id']}'>" . $list[$index]['name'] . '</a></label></li>';
09:18
it's didn't work
i want to add img name arrow.png
when i click on it the folder network appear
!!
My office time is done
now i have to go
pls try googling and study relevant examples that may help you
b bye
ok
thank you

last day (14 days later) »