我在Extjs4 librairie中遇到了一些問題。 我想使用treeEditor組件。Ext.loader未啓用缺少必填項?
Firebug的錯誤:
錯誤:未捕獲的異常:未啓用 Ext.Loader,所以 依賴性不能動態解析 。缺少必需的類: Ext.tree.TreeNode
我的代碼:
Ext.require([
'Ext.form.*',
'Ext.grid.*',
'Ext.tree.*',
'Ext.data.*',
'Ext.util.*',
'Ext.loader.*',
'Ext.state.*',
'Ext.layout.container.Column',
'Ext.tab.TabPanel'
]);
Ext.onReady(function(){
// shorthand
Ext.QuickTips.init();
var tree = Ext.create('Ext.tree.TreePanel', {
animate:false,
enableDD:false,
// loader: new Tree.TreeLoader(), // Note: no dataurl, register a TreeLoader to make use of createNode()
lines: true,
rootVisible:false,
// selModel: new Ext.tree.MultiSelectionModel(),
containerScroll: false
});
// set the root node
var root = Ext.create('Ext.tree.TreeNode',{
text: 'Autos',
draggable:false,
id:'source'
});
tree.on('contextmenu',showCtx);
tree.on('click',function(node,e){node.select();return false;});
// json data describing the tree
var json = [
{"text" : "1","allowEdit" : true, "id" : 300, "leaf" : false, "cls" : "folder", "children" : [
{"text" : "11","allowEdit" : true, "id" : 3000, "leaf" : false, "cls" : "folder","children" :[
{"text" : "111","allowEdit" : true, "id" : 300, "leaf" : false, "cls" : "folder","children" :[
{"text" : "1111","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"},
{"text" : "1112","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"},
{"text" : "1113","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"}
]},
{"text" : "112","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"},
{"text" : "113","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"}
]},
{"text" : "12","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"},
{"text" : "13","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"}
]},
{"text" : "2","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file"},
{"text" : "3","allowEdit" : true, "id" : 300, "leaf" : true, "cls" : "file",iconCls:'node'}
];
for(var i = 0, len = json.length; i < len; i++) {
root.appendChild(tree.getLoader().createNode(json[i]));
}
var ge = Ext.create('Ext.tree.TreeEditor',tree,{},{
allowBlank:false,
blankText:'Nom du dossier',
selectOnFocus:true,
cancelOnEsc:true,
completeOnEnter:true,
ignoreNoChange:true,
updateEl:true
});
/*ge.on('beforestartedit', function(){
if(!ge.editNode.attributes.allowEdit){
return false;
}
});*/
tree.setRootNode(root);
tree.render();
root.expand(true);
});
謝謝:)
它不工作了! 我有這個錯誤後: Erreur:未捕獲的異常:嘗試加載類'Ext.tree錯誤。TreeEditor'from path'./tree/TreeEditor.js':undefined – Mepps 2011-04-19 12:02:36
新的錯誤是因爲Ext JS源代碼中沒有TreeEditor.js文件!我想你將不得不等待Sencha發佈它。 – 2011-04-19 12:07:52
哦,好的..!我在sencha doc上看到TreeGrid! 非常感謝回答:) – Mepps 2011-04-19 12:10:18