【问题标题】:Sencha Architect xtype changeSencha Architect xtype 更改
【发布时间】:2012-09-22 17:41:37
【问题描述】:

如何在 Sencha Architect 中更改 xtype?

示例:

来自:

xtype: 'list'

xtype: 'RefreshableList'

【问题讨论】:

    标签: sencha-touch-2 sencha-architect


    【解决方案1】:

    作为免责声明,我是 Sencha Architect 产品的首席工程师之一。

    拖出一个列表作为顶级组件。所有顶级组件都是它们自己的类。将userAliasuserClassName 配置设置为“refreshablelist”和“RefreshableList”等值。看看为此生成的代码。

    拖出一个Panel作为顶层组件,将inspector中已有的RefreshableList拖到新的Panel中。提示将询问您是否要移动、复制或链接列表,选择“链接”。这将创建您的子类 RefreshableList 的实例。

    这是目前在 Architect 中执行此任务的最佳方式。如果您在 Architect 之外构建 RefreshableList 组件并希望在流程中链接它,情况会有所不同。您将必须创建一个覆盖并更改您在那里实例化的 xtype。我们正试图在 Sencha Architect 2.2 中解决这个限制。您将能够指定我们当前所称的 createAlias。这是要创建的别名(xtype、ptype、type 等)。

    例如,如果您拖出一个面板,然后将一个列表放入其中,您可以在检查器中选择该列表并将createAlias 配置为“RefreshableList”。这会将生成代码中的 xtype 从“list”替换为“RefreshableList”。它不会改变 Architect 内部画布上呈现的内容。您必须通过 JS 资源和/或动态加载器/需要功能加载 RefreshableList 类。

    【讨论】:

    • 感谢@aaron-conran,但它假定子类将属于控制器、视图、模型或存储的项目。我目前正在处理一个需要解决sencha.com/forum/… 的 Sencha Architect 项目,并且无法以您描述的方式子类化 JsonWriter。有什么想法吗? :)
    • 从资源 -> JS 资源添加文件。这是一个原始的 JavaScript 文件,在我们加载库后将被包含在内。完全覆盖 JsonWriter 可能是最简单的。我们在 Architect 2.2 中提供了一些功能,使这变得更加容易。最好在 Architect 帮助论坛中创建您自己的主题,我们可以为您提供帮助。
    【解决方案2】:

    您必须通过扩展列表类来创建自己的类,并为其赋予您自己的小部件别名。本教程应有尽有:http://www.sencha.com/learn/how-to-use-classes-in-sencha-touch-2/

    更新

    这是一个非常基本的自定义列表的一些代码

    //this follows the MVC structure, if you wanted you could also do something like ux.RefreshableList
    Ext.define('myAppName.view.RefreshableList', {
        extend: 'Ext.dataview.List',
        xtype: 'RefreshableList',
        config: {
            fullscreen: true,
            itemTpl: '{title}',
            data: [
                { title: 'Item 1' },
                { title: 'Item 2' },
                { title: 'Item 3' },
                { title: 'Item 4' }
            ]
        },
        initialize: function() {
            this.callParent();
        }
    });
    

    【讨论】:

    • 好的,但我正在使用 Sencha Architect,我不知道如何创建自定义类。有一些代码示例吗?谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    • 2013-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多