我想像iPad一样动态设置左侧导航菜单。
因此,我对演示示例进行了一些修改。您也可以访问此官方示例here

sink.StructureStore = new Ext.data.TreeStore({
    model: 'Demo',
    //root: {
    //    items: sink.Structure
    //},
    proxy: {
        type: 'ajax',
        url: 'words.json',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});


为了更容易实现,我尝试从“ words.json”获取JSON数据。
(理想情况下,JSONP类型更好...尝试过,但是没有运气。)

这是“ words.json”的内容:

{
    text: 'User Interface',
    cls: 'launchscreen',
    items: [{
        text: 'Buttons',
        card: demos.Buttons,
        source: 'src/demos/buttons.js',
        leaf: true
    },
    {
        text: 'Forms',
        card: demos.Forms,
        source: 'src/demos/forms.js',
        leaf: true
    },
    {
        text: 'List',
        card: demos.List,
        source: 'src/demos/list.js',
        leaf: true
    }]
}


最终什么也没出现。怎么了?我会误会吗? (API here

我要怎么办

像字典一样,左侧是单词的导航项。单击它后,该单词的含义将在右侧视图中显示。

我无法在 sencha framework中运行NestedList示例。我想要做的是单击表格单元格并在其上推送另一个视图(即,在Sencha中:NestedList)。

尝试过但没有运气:


使用NestedList示例
用ScriptTagProxy(JSONP)替换代理
使用更容易的代理实现(如代码所示)


我不确定我的描述是否足够清楚,请随时告诉我哪一部分不清楚。并预先感谢!

最佳答案

如果words.json看起来像上面的内容,那可能是您的问题。

这就是它的外观。

{
    "text": "User Interface",
    "cls": "launchscreen",
    "items": [{
        "text": "Buttons",
        "source": "src/demos/buttons.js",
        "leaf": true
    }, {
        "text": "Forms",
        "source": "src/demos/forms.js",
        "leaf": true
    }, {
        "text": "List",
        "source": "src/demos/list.js",
        "leaf": true
    }]
}


我还使用内存代理(默认)和ajax代理附加了您想要的内容的完整工作副本。

Ext.regApplication({
    name: 'test',
    launch : function(){
        var nL = new Ext.NestedList({
            store: test.stores.testTreeStore,
            fullscreen: true,
            itemTextTpl : '{text}'
        });
    }
});
Ext.ns('test.data');

test.data.words = {
    text: 'User Interface',
    cls: 'launchscreen',
    items: [{
        text: 'Buttons',
        source: 'src/demos/buttons.js',
        leaf: true
    },
    {
        text: 'Forms',
        source: 'src/demos/forms.js',
        leaf: true
    },
    {
        text: 'List',
        source: 'src/demos/list.js',
        leaf: true
    }]
};

test.models.testTreeModel = Ext.regModel('testTreeModel', {
    fields: ['text','source','card','leaf'],
    proxy: {
        type: 'memory',
        data: test.data.words,
        //type: 'ajax',
        //url: 'words.json',
        reader: {
            type: 'json',
            root: 'items'
        }
    }
});
test.stores.testTreeStore = new Ext.data.TreeStore({
    model: 'testTreeModel'
});

07-24 09:44
查看更多