Rumah >hujung hadapan web >tutorial js >ExtJs menjana format Json treepanel_jquery secara dinamik
Tambahkan atribut "ditandai" pada nod dan kotak pilihan akan dijana secara automatik.
Dapatkan nod yang dipilih
var nodeArray = ""; var nodesObj = mytree.getChecked(); var i;var length=nodesObj .length; for (i = 0; i < length; i++) { nodeArray += nodesObj[i].id + ','; //允许多选的情况。如果不允许多选,就直接nodesObj[i].id } nodeArray = nodeArray.substring(0, nodeArray.length - 1);
Format Json adalah seperti berikut:
[{ "text": "To Do", "cls": "folder", "expanded": true, "children": [{ "text": "Go jogging", "leaf": true, "checked": true },{ "text": "Take a nap", "leaf": true, "checked": false },{ "text": "Climb Everest", "leaf": true, "checked": false }] },{ "text": "Grocery List", "cls": "folder", "children": [{ "text": "Bananas", "leaf": true, "checked": false },{ "text": "Milk", "leaf": true, "checked": false },{ "text": "Cereal", "leaf": true, "checked": false },{ "text": "Energy foods", "cls": "folder", "children": [{ "text": "Coffee", "leaf": true, "checked": false },{ "text": "Red Bull", "leaf": true, "checked": false }] }] },{ "text": "Remodel Project", "cls": "folder", "children": [{ "text": "Finish the budget", "leaf": true, "checked": false },{ "text": "Call contractors", "leaf": true, "checked": false },{ "text": "Choose design", "leaf": true, "checked": false }] }]
Di atas adalah keseluruhan kandungan artikel ini, saya harap anda semua menyukainya.