【问题标题】:MVC Data Store - WebORB, Sencha, Ext Js 4MVC 数据存储 - WebORB、Sencha、Ext Js 4
【发布时间】:2013-05-17 15:19:09
【问题描述】:

我正在尝试使用 EXT JS 4、Sencha Touch 2.0 和 WebORB。

我正在尝试通过 Ext 动态地在 Sencha Touch 的 MVC 中建立一个商店。 我在 Index.html 的部分中调用了以下 javascript 函数:

<script src="sencha-touch-all.js"></script>
                <script src="webORB.js"></script>
                <script>
                var dataFetched;
                var dataGet=function(){
        <!--  Class Name and URL are replaced in the original program-->
                this.proxy = webORB.bind("ClassName", "URL");
                    dataFetched=this.proxy.GetClassList(1301722);   
                //console.log(dataFetched);
            }
                </script>
                <script src="app.js">
</script>

以下是我的app.js

Ext.Loader.setConfig({
    enabled: true

});
Ext.application({
    name: 'SBR',
    controllers: [
        'Main','Blog','Comments'
    ],
    views : [
    'Home','Blog', 'Comments'
],
    models : ['Comments'],
    stores: ['Comments'],
    launch: function(){
        dataGet();
        console.log(dataFetched);
        Ext.create('SBR.view.Viewport');
    }
});

以下是我的 Comment.js - 商店

Ext.define('SBR.store.Comments',{
    extend: 'Ext.data.Store',   
    config: {
        model: 'SBR.model.Comments',
        data: dataFetched
    }

});

以下是Comment.js - 模型

Ext.define('SBR.model.Comments',{
        extend: 'Ext.data.Model',

        config: {
            //fields: ['subject','body']
            fields: ['bookImageUrl','authorFirstName','authorLastName']
        }
    })

以下是Comment.js - 查看

Ext.define('SBR.view.Comments',{
    extend: 'Ext.List',
    xtype: 'commentspage',
    config:{
        title: 'Comments',
        iconCls: 'star',
        //indexBar: true,
        store : 'Comments',
        itemTpl: '{authorLastName}',
        onItemDisclosure: function(item) {
            console.log('Disclose more info on' + " " + item.data.subject);
        }
    }
});

如果我使用静态 Json 数据定义存储,它可以正常工作,但是当我尝试使用 WebORB 访问它时却不行。

控制台条目在向控制台显示数据之前完成。为什么它没有在评论视图中显示任何数据,或者我的方法完全错误地通过 WebORB 收集和加载数据到商店?

【问题讨论】:

    标签: extjs sencha-touch-2 weborb


    【解决方案1】:

    哦,是的……我明白了……

    我刚刚更改了以下内容:

    1. 我将函数 dataget() 从 index.html 转移到 Comments.js-Store 并在同一文件的配置中调用了相同的函数,例如:

    数据:dataGet()

    就是这样……成功了……

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-14
      • 1970-01-01
      • 2013-09-14
      • 1970-01-01
      • 2012-02-20
      相关资源
      最近更新 更多