javascript - JsTree design is not proper display -
run time, try add child under parent node. when click on tree branch. call ajax file has return list structure of child , set under parent node designing not proper. find tree structure image below
$(document).on('click', '.jstree-ocl', function() { var contactid = $(this).closest('.clstwolevel').attr('id'); var groupid = $('#cbogroupname').val(); if (contactid != undefined) { $.ajax({ url: 'contact-group-treeview.php', data: 'contactid=' + contactid + '&groupid=' + groupid, type: 'post', success: function(response) { $("#morethantwolevel_"+contactid).html(response); } }); } }); <div id="jstree"> <?php while ($row = sqlsrv_fetch_array($getlevelonetwo, sqlsrv_fetch_assoc)) { ?> <ul> <li> <?php echo $row['name'] . ' (' . $row['totalcount'] . ')'; ?> <?php if ($row['totalcount'] != 0) { $getleveltewoname = get_level_tewo_name($conn, $groupid, $row['contactid']); while ($row_level_two = sqlsrv_fetch_array($getleveltewoname, sqlsrv_fetch_assoc)) { ?> <ul> <li class="clstwolevel" id="<?php echo $row_level_two['contactid']; ?>"> <?php echo $row_level_two['name'] . ' (' . $row_level_two['totalcount'] . ')' ?> <?php if ($row_level_two['totalcount'] != 0) { ?> <ul> <!--<div class="morethantwolevel"></div>--> <li class="morethantwolevel"></li> </ul> <?php } ?> </li> </ul> <?php } ?> <?php } ?> </li> </ul> <?php } ?>
ajax result
<ul> <li class="clstwolevel jstree-open" id="4710">kalpnaben jitendrabhai soni (1) </li> </ul> <ul> <li class="clstwolevel jstree-open" id="19"> ghanshyambhai kalubhai patel (3) <ul> <li class="morethantwolevel" id="morethantwolevel_19"></li> </ul> </li> </ul> <ul> <li class="clstwolevel jstree-open" id="4711">mitaben ghanshyambhai patel (1) </li> </ul>
Comments
Post a Comment