Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在extjs树编辑器中出现语法错误?_Extjs - Fatal编程技术网

为什么在extjs树编辑器中出现语法错误?

为什么在extjs树编辑器中出现语法错误?,extjs,Extjs,为什么我会犯这个错误 “SyntaxError:函数语句需要名称” 对于本文档中的代码 这些行不符合上下文,是无效的Javascript(它们应该用花括号括起来以形成对象文字)。这就是问题中解析错误的来源: onTreeNodeDblClick: function(n) { treeEditor.editNode = n; treeEditor.startEdit(n.ui.textNode); } onTreeEditComplete: function(treeEditor

为什么我会犯这个错误

“SyntaxError:函数语句需要名称”

对于本文档中的代码


这些行不符合上下文,是无效的Javascript(它们应该用花括号括起来以形成对象文字)。这就是问题中解析错误的来源:

onTreeNodeDblClick: function(n) {
    treeEditor.editNode = n;
    treeEditor.startEdit(n.ui.textNode);
}

onTreeEditComplete: function(treeEditor, o, n) {
    //o - oldValue
    //n - newValue
}
以下是您可以修复它的方法。请注意我的评论。。。一旦修复了第一个错误,您可能会遇到更多错误:

var tree = new Ext.tree.TreePanel({
    // The following function won't be defined, you'll have to configure
    // a working root to make this example work... And possibly more!
    root: this.getChildren(),
    height: 300,
    loader: new Ext.tree.TreeLoader(),
    useArrows: true,
    autoScroll: true,
    listeners: {
        dblclick: onTreeNodeDblClick
    }
});

var treeEditor = new Ext.tree.TreeEditor(tree, {}, {
    cancelOnEsc: true,
    completeOnEnter: true,
    selectOnFocus: true,
    allowBlank: false,
    listeners: {
        complete: onTreeEditComplete
    }
});

// It seems that the intention of the author was to declare independent 
// functions (as opposed to object methods).
function onTreeNodeDblClick(n) {
    treeEditor.editNode = n;
    treeEditor.startEdit(n.ui.textNode);
}

function onTreeEditComplete(treeEditor, o, n) {
    //o - oldValue
    //n - newValue
}

您正在使用哪个版本的Ext JS
Ext.tree.TreeEditor
是Ext JS 3组件,它在当前Ext JS 4中不再存在。如果我是你,我正在使用3.4版本,如果你自己的研究没有产生任何有趣的结果,我会在这里问另一个问题。如果您可以将一个工作代码示例放在一起构建(理想情况下是在a中),那么您肯定会很快得到答案!