Example #1
0
function print_recursive_menu($data)
{
    $str = "";
    foreach ($data as $list) {
        $subchild = print_recursive_menu($list['child']);
        if ($subchild != '') {
            //$str.= '"children" :[';
            $str .= '{ "text" : "' . $list['nama'] . '",';
            //anchor($list['link'],$list['nama'])
            $str .= '"children" :[';
            $subchild = print_recursive_menu($list['child']);
            $str .= '';
            //$str.= ']';
            $str .= $subchild;
            $str .= ']},';
        } else {
            //jika tdk punya anak lg
            //$str.= '"children" :[';
            $str .= '{ "text" : "' . $list['nama'] . '"},';
            //anchor($list['link'],$list['nama'])
            $subchild = print_recursive_menu($list['child']);
            $str .= $subchild;
        }
    }
    return $str;
}
Example #2
0
<script>
var UITree = function () {
	var handleSample3 = function () {
        $('#tree_3').jstree({
            'plugins': ["wholerow", "checkbox", "types"],
            'core': {
                "themes" : {
                    "responsive": false
                },    
                'data': [
				<?php 
foreach ($multilevel as $data) {
    echo '{';
    echo '"text" : "' . $data['nama'] . '",';
    echo '"children" :[';
    echo print_recursive_menu($data['child']);
    echo ' ]';
    echo '},';
}
?>
				]
            },
            "types" : {
                "default" : {
                    "icon" : "fa fa-folder icon-state-warning icon-lg"
                },
                "file" : {
                    "icon" : "fa fa-file icon-state-warning icon-lg"
                }
            }
        });