【问题标题】:Model data doesn't show on tableviewrow (Titanium Studio)模型数据不显示在 tableviewrow (Titanium Studio)
【发布时间】:2015-04-27 16:25:55
【问题描述】:

我从 Titan Studio 开始,我遵循了有关 Titan 文档的“创建您的第一个应用程序”教程。到目前为止,这是我的代码:

evento.js(模型)

exports.definition = {
    config: {
        columns: {
            "descricao": "string",
            "realizado": "boolean"
        },
        adapter: {
            type: "sql",
            collection_name: "eventos"
        }
    },
    extendModel: function(Model) {
        _.extend(Model.prototype, {
            // extended functions and properties go here
        });

        return Model;
    },
    extendCollection: function(Collection) {
        _.extend(Collection.prototype, {
            // extended functions and properties go here
        });

        return Collection;
    }
};

index.js(控制器)

var meusEventos = Alloy.Collections.eventos;
var evento = Alloy.createModel('eventos',{
    descricao: 'Principiantes',
    realizado: true
});


meusEventos.add(evento);
evento.save();
meusEventos.fetch();
$.index.open();

index.xml(视图)

<Alloy>
    <Collection src="eventos"/>
    <Window class="container">
        <TableView dataCollection="eventos">
            <TableViewRow descricao="{descricao}" realizado="{realizado}"></TableViewRow>
        </TableView>
    </Window>
</Alloy>

但是当我在我的 fone 上运行应用程序时,它不显示任何 tableviewrows。我在这里做错了什么?

【问题讨论】:

    标签: android titanium titanium-alloy


    【解决方案1】:
    <Alloy>
    <Collection src="eventos"/>
    <Window class="container">
        <TableView dataCollection="eventos">
            <TableViewRow descricao="{descricao}" realizado="{realizado}"></TableViewRow>
        </TableView>
    </Window>
    </Alloy>
    

    它创建了一个自定义属性名称 descricaorealizado 尝试在TableViewRow 中使用属性title,例如:

    <TableViewRow title="{descricao}" realizado="{realizado}">
    

    希望这会对你有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多