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

Alloy ignoring dataTransform and dataFilter

$
0
0

I've a simple collection with restapi adapter (MyCollection.js):

exports.definition = {  
    config: {
        URL: "http://www.xxx.xxx/api/myCollection",
        debug: 1, 
        adapter: {
            type: "restapi",
            collection_name: "myCollection",
            //idAttribute: "id"
        },
    },      
    extendModel: function(Model) {      
        _.extend(Model.prototype, {});
        return Model;
    },  
    extendCollection: function(Collection) {        
        _.extend(Collection.prototype, {});
        return Collection;
    }       
};
In the controller (index.js):
$.index.open();
 
function doTransform(model) {
    var transform = model.toJSON();
    Ti.API.debug(transform);
    return transform;
}
 
function dofilter(collection) {
    Ti.API.debug(collection);
}
 
var list = Alloy.Collections. myCollection;
myCollection.fetch();
 
$.index.addEventListener('close', function() {
    $.destroy();
});
and the view (index.xml)
<Alloy>
    <Collection src="myCollection" />
    <Window class="container">
        <TableView dataCollection="myCollection" dataTransform="doTransform" dataFilter="doFilter">
            <TableViewRow title="{title}" />
        </TableView>
    </Window>
</Alloy>
and in the Alloy.js
Alloy.Collections. myCollection = Alloy.createCollection("myCollection");
The REST call return JSON data but the TableView is always empty and the Ti.API.debug function in doTransform is never executed… Were am I doing wrong?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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