0

I am getting an error Cannot read property '__transform' of null data binding issue.

The line of code of the corresponding error from the resources section:

text: "undefined" != typeof $model.__transform["topic"] ? $model.__transform["topic"] : $model.get("topic")

I assume that somehow the model is not getting referenced correctly. Here is my model code. It is in file chatThreadSQL.js in the models directory:

exports.definition = {
config: {
    "columns": {
    "uuid":"TEXT UNIQUE PRIMARY KEY",
    "topic": "TEXT", 
    "created":"TEXT",
    //"patient": "",
    },
adapter: {
    "type": "sql",
    "collection_name": "chatThreadSQL_col",
    // idAttribute tells Alloy/Backbone to use this column in
    // my table as its unique identifier field. Without
    // specifying this, Alloy's default behavior is to create
    // and "alloy_id" field which will uniquely identify your
    // rows in the table with a text GUID.
    "idAttribute": "uuid"
    }
},  

extendModel: function(Model) {  
    _.extend(Model.prototype, {

        // extended functions go here

    }); // end extend

    return Model;
},


extendCollection: function(Collection) {    
    _.extend(Collection.prototype, {

        // extended functions go here

    }); // end extend

    return Collection;
}

};

I have verified that data is being inserted into sqlite3 using adb shell.

Here is my view definition, for view file chatHome.xml

   <TableView dataCollection="chatThreadSQL"  id="table2">
        <TableViewSection>
        <TableViewRow id="row" title="{topic}" onClick="openChats" model="{uuid}" backgroundSelectedColor="#000080">
            <Label id="title" text="{topic}"/>
            <Label id="date" text="{date}"/>
        </TableViewRow>
        </TableViewSection>
   </TableView>

in controllers/chatHome.js, I have the following line at the top of my file:

var chatThreads = Alloy.Collections.chatThreadSQL;

Any pointers would be greatly appreciated!

Other Info:

Application type: mobile
Titanium SDK: 3.1.3
Platform & version: Android 4.
Host Operating System: Ubuntu 13.04
Thom Wiggers
  • 6,938
  • 1
  • 39
  • 65

1 Answers1

0

You set your collection name to chatThreadSQL_col, so you have to reference it that way in code.

Try:

 <TableView dataCollection="chatThreadSQL_col"  id="table2">
        <TableViewSection>
        <TableViewRow id="row" title="{topic}" onClick="openChats" model="{uuid}" backgroundSelectedColor="#000080">
            <Label id="title" text="{topic}"/>
            <Label id="date" text="{date}"/>
        </TableViewRow>
        </TableViewSection>
   </TableView>
Josiah Hester
  • 6,065
  • 1
  • 24
  • 37
  • Thank Josiah. This is a reasonable suggestion, but unfortunately does not work. Check out https://github.com/aaronksaunders/alloy_fugitive/blob/master/app/models/Fugitive.js "Fugitive" is given a collection name "fugitives", but is referenced as collection name "Fugitive" in https://github.com/aaronksaunders/alloy_fugitive/blob/master/app/views/Fugitives.xml – Saumya Garg Oct 06 '13 at 21:21
  • Put a breakpoint on it, debug and report back if there is anything in the collection. – Josiah Hester Oct 06 '13 at 21:26