javascript - Sencha 触摸 2 : Passing data from controller to a view

标签 javascript model-view-controller mobile sencha-touch sencha-touch-2

我试图从列表中加载项目披露的详细 View ,但没有使用 NavigationView 和“push()”命令。

Controller :

Ext.define('App.controller.MyPlans', {
    extend: 'Ext.app.Controller',
    requires: ['App.view.EventDetail',
        'App.view.PlansContainer'],

    config: {
        refs: {

        },
        control: {
            'MyPlansList': {
                disclose: 'onDisclose'
            }
        }
    },

    onDisclose: function (view, record) {
        console.log("My Plans list disclosure " + record.get('id'));
        var eventDetailView = Ext.create('App.view.EventDetail');
        eventDetailView.setRecord(record);
        Ext.Viewport.setActiveItem(eventDetailView);
    }
});

View :

Ext.define('App.view.EventDetail', {
    extend: 'Ext.Panel',
    xtype: 'EventDetail',

    config: {

        items: [{
            xtype: 'toolbar',
            docked: 'top',
            title: 'Event Name',
            items: [{
                xtype: 'button',
                id: 'addRunBackBtn',
                ui: 'back',
                text: 'Back'
            }]
        }, {
            xtype: 'panel',
            styleHtmlContent: true,
            itemTpl: [
                '<h1>{name}</h1>',
                '<h2>{location}</h2>',
                '<h2>{date}</h2>']
        }],

    }
});

我主要是尝试使用“setRecord()”命令将数据传递给 View ,但 View 中似乎没有加载任何内容。有什么想法吗??

谢谢

最佳答案

只写 Tpl 而不是 ItemTpl。我怀疑 itemTpl 在没有列表 xtype 的情况下是否存在。

其他的东西是把 Tpl 放在配置里面:

{tpl:['<div class="ListItemContent">{descriptionddata}</div>']}

我之前/上面的答案很好,但是如果你打算将你的格式保留在 View 中而不是在 Controller 中,那么它可以通过使用 setData 而不是 setRecord 来工作

detailview.setData({title:record.get('title'), description:record.get('descriptiondata')});

关于javascript - Sencha 触摸 2 : Passing data from controller to a view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13408871/

相关文章:

javascript - 如果两个波浪号之间的字符数大于 60,则在两个波浪号字符之间添加波浪号

javascript - jQuery MVC 架构

javascript - 如何使用像backbone.js或angular.js这样的现代js框架将遗留的simgle网页/应用程序重构为MVC

javascript - 当我改变我的移动 View 时我的图像的位置

android - 完全独立的 Rails 移动应用程序,编译为 native 应用程序

android - 如何在 SQLite android 中手动执行检查点?

javascript - 'sync' 事件和 Backbone.sync 是否都以某种方式连接——两者之间有什么区别?

javascript - Promise.all 在一个异步函数中

javascript - 获取可编辑div中的光标父级

c++ - View 类未接收更新的模型类数据