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

Unable to fetch all the rows using model

$
0
0

Hi All,

I am working on an ios app using titanium sdk 3.2.0, Alloy framework 1.3.0 and testing it using ios simulator.

I have a tableview inside a view and there is sqlite file 'readGrid.sqlite' which I have stored in assets folder andhas my desired table having 2 rows of data. I am able to retrieve(fetch) only 1 row out of 2. Here is my xml file looks like : grid.xml

<Alloy>
    <View class="container" id="gridViewId">
        <TableView id="readGrid" dataCollection="readGrid" onClick="readGridClick" dataTransform="transformData">
            <Require src="row"></Require>
        </TableView>
    </View>
</Alloy>
row.xml
<Alloy>
    <TableViewRow id="gridRow">
        <Label id="eventDate" text="{eventDate}"></Label>
        <Label id="fname" text="{firstName}"/>
        <Label id="lname" text="{lastName}"></Label>        
    </TableViewRow>
</Alloy>
readGrid.js(model)
exports.definition = {
    config: {
        "adapter": {
            "type": "sql",
            "collection_name": "readGrid",
            "db_file": "/readGrid.sqlite",
            "db_name": "readGrid",
            "idAttribute": "policyNumber",
            "remoteBackup": false
    },
    }
};
grid.js
var readGrid = Alloy.Collections.readGrid;
 
function transformData(model) {
    var attrs = model.toJSON();
    Ti.API.info('attrs: ' + JSON.stringify(attrs)); //it is retrieving only single row
    return attrs;
}
readGrid.fetch({query:'Select * from readGrid'});
Ti.API.info("readGrid = "+JSON.stringify(readGrid));    //it is retrieving only single row
row.js
if ($model) {
    $.gridRow.model = $model.toJSON();
}
This is my code. Can anyone please tell me where am I going wrong in here? Thanks in advance.

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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