Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

ListView data binding - single model instance binding does not work

$
0
0

Expected Result

Show binding values on list item

Actual Result

Nothing is showing.....

index.js

$.sports.fetch({
    "id" : 39
});
 
//{"id" : 39, "name" : 'A', "host_organization" : 'C', "event_code" : "30/07/2014" }
 
$.index.open();
index.xml
<Alloy>
    <Model id="sports" src="adidas" instance="true"/>
    <Window fullscreen="true" backgroundColor="white">
        <ListView>
            <ListSection>
                <ListItem title="{$.sports.host_organization}" accessoryType="Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE"/>
                <ListItem title="{$.sports.name}" accessoryType="Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE"/>
                <ListItem title="{$.sports.id}" accessoryType="Ti.UI.LIST_ACCESSORY_TYPE_DISCLOSURE"/>
            </ListSection>
        </ListView>
    </Window>
</Alloy>
adidas.js
exports.definition = {
    config : {
        columns : {
            "id" : "INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE",
            "name" : "TEXT",
            "host_organization" : "TEXT",
            "event_code" : "TEXT UNIQUE"
        },
        "defaults" : {
            "id" : "",
            "name" : "",
            "host_organization" : "",
            "event_code" : ""
        },
        adapter : {
            "type" : "sql",
            "collection_name" : "adidas",
            "idAttribute" : "id",
            "db_name" : "davidTest",
            "db_file" : "/davidTest.sqlite"
        }
    },
    extendModel : function(Model) {
        _.extend(Model.prototype, {
            // extended functions and properties go here
            persistDefaultEvent : function() {
                var event_code = Alloy.Globals.moment().format('L');
 
                var rawSql = "INSERT INTO adidas(name, host_organization, event_code) SELECT 'A', 'C', '36/07/2014' WHERE NOT EXISTS(SELECT 1 FROM adidas WHERE event_code = '36/07/2014')";
                var paramSql = "INSERT INTO adidas(name, host_organization, event_code) SELECT ?, ?, ? WHERE NOT EXISTS(SELECT 1 FROM adidas WHERE event_code = ?);";
                Alloy.Globals.DB.open();
                Alloy.Globals.DB.execute(paramSql, ['A', 'C', '37/07/2014', '37/07/2014']);
                Alloy.Globals.DB.close();
            }
        });
 
        return Model;
    },
    extendCollection : function(Collection) {
        _.extend(Collection.prototype, {
            // extended functions and properties go here
        });
 
        return Collection;
    }
};

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>