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

Trouble using dataTransform on TableView

$
0
0

I am having an issue using dataTransform on a TableView. If I do not specify a transformation function on the TableView the data binding works and creates the rows with the models from the collection. As soon as I specify a dataTransform function, as seen below, I get the following error. When I step through the doTransform function the model is indeed 'undefined'. Can anyone see anything I am doing wrong here?

message = "'undefined' is not an object (evaluating 'model.toJSON')";
alloy.js
Alloy.Collections.brewery = Alloy.createCollection('brewery');
index.xml
var brewery = Alloy.Collections.brewery;
brewery.fetch();
 
function doTransform(model) {
    Ti.API.info("In ==> doTransform");
    var transform = model.toJSON();
    transform.LOCATION = '[' + transform.LOCATION + ']';
    return transform;
}
 
// filter collection
function filterFunction(collection) {
    Ti.API.info("In ==> filterFunction");
    return collection;
}
 
$.index.open();
index.xml
<Alloy>
    <Window>
        <TableView id="table" dataCollection="brewery" 
                dataFilter="filterFunction" dataTransform="doTransform">
            <TableViewRow id="{ID_BREWER}">
                <Label id="name" text="{NAME}"/>
                <Label id="loc" text="{LOCATION}"/>
            </TableViewRow>
        </TableView>
    </Window>
</Alloy>
Thanks in advance for any insight!

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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