未在钛 TableViewRow 中显示的项目

items not displaying in titanium TableViewRow

我正在创建简单的 Titanium Book 示例应用程序的变体。
我正在连接的 Nexus 7 上启动该应用程序。 该应用程序启动,但未显示我的示例数据。 我看不出是什么导致它失败。

Index.xml如下:

<Alloy>
    <Collection src="item"/> 
    <TabGroup>
        <Tab title="Items" icon="KS_nav_ui.png"> -->
            <Window class="container" title="Items">
                <!-- Add TableView and  TableViewRow -->
                <TableView dataCollection="item">
                    <TableViewRow label="{label}" description="{description}" onClick="showItem"></TableViewRow>
                </TableView>
                <Menu id="menu" platform="android">
                    <MenuItem
                    title="Add book"
                    onClick="addBook"
                    showAsAction="Ti.Android.SHOW_AS_ACTION_IF_ROOM" />
                </Menu>
            </Window>
        </Tab>
        <Tab title="Admin" icon="KS_nav_views.png">
            <Window title="Manage your listings">
                <Label>Table of stuff to manage</Label>
            </Window>
        </Tab>
    </TabGroup>
</Alloy>

Indix.js

var myItems = Alloy.Collections.item;

//Create some sample items so that we have something to style.
//This will eventually grab data from the bootstrap sync method.
var item1 = Alloy.createModel('item', {
            taken_by: 0,
            taken_time: 0,
            label: 'Attivo Maestro',
            creator: 1,
            enabled: 1,
            location: 1,
            description: "Today the Maestro model is the most technologically advanced ski on the market. It represents the big news for skiers looking for maximum performance uphill and downhill. Attivo shock absorber technology makes the difference.",
            created: "2015-02-14 13:19:21",
            image: "http://skitrab.com/upload/products_/158/attivo_skis.jpg",
            price: 1,
            currentPrice: 765,
            topic: 1,
            deleted: 0
        });

myItems.add(item1);
item1.save();

function showItem(event) {
    var selectedItem = event.source;
    var args = {
        label : selectedItem.label,
        description : selectedItem.description
    };
    var Itemview = Alloy.createController("Itemdetails", args).getView();

    if (OS_IOS) {
        $.navGroupWin.openWindow(Itemview);
    }
    if (OS_ANDROID) {
        Itemview.open();
    }
}

function addItem(){
    var myAddItem = Alloy.createController("addItem",{}).getView();
    if (OS_IOS) {
        $.navGroupWin.openWindow(myAddItem);
    }
    if (OS_ANDROID) {
        myAddItem.open();
    }
}
$.index.open();

item.js:

exports.definition = {
    config: {
        columns: {
            "taken_by": "integer",
            "taken_time": "integer",
            "label": "text",
            "creator": "integer",
            "enabled": "integer",
            "location": "integer",
            "description": "text",
            "created": "text",
            "image": "text",
            "price": "integer",
            "currentPrice": "integer",
            "topic": "integrer",
            "deleted": "text"
        },
        adapter: {
            idAttribute: "itemid",
            type: "sql",
            collection_name: "item"
        }
    },
    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;
    }
};

我觉得一切都很好,编译没有任何错误。有些警告似乎不相关,但它们是:

[WARN] :   linker: libstlport_shared.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[WARN] :   linker: libtiverify.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[WARN] :   linker: libkroll-v8.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[INFO] :   TiApplication: (main) [308,465] Titanium Javascript runtime: v8
[INFO] :   TiRootActivity: (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
[WARN] :   V8Object: (KrollRuntimeThread) [174,174] Runtime disposed, cannot set property 'userAgent'

它加载到 nexus 上,出现初始屏幕,然后应用程序以两个选项卡启动,但是 tab1 中没有内容,我认为它应该有项目标签和描述。

有人有什么想法吗?

谢谢

好的,所以最后的答案很简单。在 titanium 教程中,他们有一个名为 Favebooks 的示例,其中的书有标题和作者。

要在 TableViewRow 中显示标题,请执行以下操作(在他们的示例中)

<TableViewRow title="{title}" author="{author}" onClick="showItem"></TableViewRow>

我出于自己的目的修改了它。我有一个带有标签和描述的项目,将 TableViewRow 行更改为 read

似乎很自然
<TableViewRow label="{label}" description="{description}" onClick="showItem"></TableViewRow>

但是这样不行,你需要把

<TableViewRow title="{label}" description="{description}" onClick="showItem"></TableViewRow>

看来书名和TableViewRow的标题是两个不同的东西。希望对某人有所帮助...