Extension of dijit.Tree widget with checkboxes, using ForestStoreModel. Tested with dojotoolkit 1.7.
See test.html as an example with CDN loading and AMD format.
require([
"dojo/dom",
"my_ext/CheckboxTree", // "dijit/Tree",
"dojo/data/ItemFileWriteStore",
"my_ext/CheckboxForestStoreModel", // "dijit/tree/ForestStoreModel",
"dijit/form/Button",
"dojo/domReady!"
], function(dom, Tree, ItemFileWriteStore, ForestStoreModel, Button) {
var treeData = {
'identifier': 'name',
'label' : 'description',
'items' : [
{ 'name' : 'node1', 'description' : 'node1', 'checked' : true },
{ 'name' : 'node2', 'description' : 'node2', 'children' : [
{ 'name' : 'node3', 'description' : 'node3', 'checked' : false },
{ 'name' : 'node4', 'description' : 'node4', children : [
{ name : 'node5', description : 'node5', checked : true },
{ name : 'node6', description : 'node6' }
]}
]},
{ 'name' : 'node7', 'description' : 'node7 description', 'checked' : true },
]};
var treeStore = new ItemFileWriteStore({ data : treeData });
var treeModel = new ForestStoreModel({
store: treeStore,
childrenAttrs: ["children"]
});
var tree = new Tree({
id : "tree",
model : treeModel,
showRoot : false,
openOnClick : false,
setCheckboxOnClick : true
},
'treeDiv');
tree.startup();
...
});