第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Laravel生成jstree的json數(shù)據(jù)

Laravel生成jstree的json數(shù)據(jù)

慕桂英3389331 2018-08-13 14:18:40
laravel從數(shù)據(jù)庫(kù)中取出來(lái)的數(shù)據(jù)如何封裝成jstree能夠讀取的模型?如果有能給個(gè)實(shí)例就好了……$("#tree_4").jstree({    core: {        themes: {            responsive: !1        },        check_callback: !0,        data: {            url: function (e) {                return "{{ route('api.deparment') }}"            },            data: function (e) {                return {                    parent: e.id                }            }        }    },    types: {        "default": {            icon: "fa fa-folder icon-state-warning icon-lg"        },        file: {            icon: "fa fa-file icon-state-warning icon-lg"        }    },    state: {        key: "demo3"    },    plugins: ["dnd", "state", "types"]})
查看完整描述

1 回答

?
慕運(yùn)維8079593

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊

把你數(shù)據(jù)庫(kù)取出的數(shù)據(jù)遍歷一下,json結(jié)構(gòu)官方的github已經(jīng)給出了

[{  "id":1,"text":"Root node","children":[
    {"id":2,"text":"Child node 1"},
    {"id":3,"text":"Child node 2"}
  ]
}]

這是我做的例子

[
    {        "id": 1, 
        "text": "root", 
        "value": "root", 
        "pid": 0, 
        "type": 0, 
        "children": [
            {                "id": 2, 
                "text": "Status", 
                "value": "status", 
                "pid": 1, 
                "type": 1, 
                "children": [
                    {                        "id": 5, 
                        "text": "open", 
                        "value": "open", 
                        "pid": 2, 
                        "type": 1
                    }, 
                    {                        "id": 6, 
                        "text": "cancelled", 
                        "value": "cancelled", 
                        "pid": 2, 
                        "type": 1
                    }
                ]
            }, 
            {                "id": 3, 
                "text": "Payment Status", 
                "value": "financial_status", 
                "pid": 1, 
                "type": 1, 
                "children": [ ]
            }, 
            {                "id": 4, 
                "text": "Tagged With", 
                "value": "tag", 
                "pid": 1, 
                "type": 1, 
                "children": [ ]
            }, 
            {                "id": 7, 
                "text": "Date", 
                "value": "process_at", 
                "pid": 1, 
                "type": 1, 
                "children": [
                    {                        "id": 8, 
                        "text": "in the last week", 
                        "value": "past_week", 
                        "pid": 7, 
                        "type": 1
                    }, 
                    {                        "id": 9, 
                        "text": "on or before", 
                        "value": "processed_at_max", 
                        "pid": 7, 
                        "type": 2
                    }
                ]
            }, 
            {                "id": 10, 
                "text": "Custom", 
                "value": "custom", 
                "pid": 1, 
                "type": 2, 
                "children": [ ]
            }
        ]
    }
]

https://img1.sycdn.imooc.com//5ba1b17a0001108a03130239.jpg


查看完整回答
反對(duì) 回復(fù) 2018-09-19
  • 1 回答
  • 0 關(guān)注
  • 1017 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)