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

Unable to load tableviewrows from ACS files

$
0
0

Application Type: Mobile Titanium SDK: Titanium SDK Version: 3.4.0.GA Platform: IOS 8.1.3 Device Device: Iphone 5s:

Hi,

I'm struggeling creating tableviewrows from the data stored in the files table of ACS.I'm able to retrieve the data from ACS but unable to get some data from a files object to a tableview row. The code below works for me with a collection based on a sqlite db. Now I created a ACS based collection and it won't populate my tableviewrows. I also added the ACS adapter to the Assets/alloy/sync/ folder. Hope someone can help me with my code. Is the method I'm using at all possible with the ACS or could I better approach this in a different way.

This is the code I have: models/cloudRecordings.js

exports.definition = {
    config : {
        "columns" : {
        },
        "defaults" : {},
        "adapter" : {
            "type" : "acs",
        },
        "settings" : {
            "object_name" : "files",
            "object_method" : "Files"
        }
    },
 
    extendModel : function(Model) {
        _.extend(Model.prototype, {
        });
        // end extend
        return Model;
    },
 
    extendCollection : function(Collection) {
        _.extend(Collection.prototype, {
        });
        // end extend
        return Collection;
    }
};
views/cloudFiles.xml
<Alloy>
    <Window>
        <Label id="cloudTitle">Cloud files</Label>
        <TableView id="cloudTable" dataCollection="cloudRecordings" dataTransform="transformCloudData"> 
            <Require src="cloudRow"/>
        </TableView>
    </Window>
</Alloy>
controllers/cloudFiles.js
var cloudRecordings = Alloy.createCollection('cloudRecordings');
 
    function showId(e) {
    if (e.row.model) {
        alert(e.row.model);
    }
}
 
    function transformCloudData(model) {
    var cloudAttrs = model.toJSON();
    Ti.API.info('cloudAttrs: ' + JSON.stringify(cloudAttrs));
    return cloudAttrs;
};
 
    cloudRecordings.fetch();

controllers/cloudRow.xml

<Alloy>        
            <TableViewRow selectionStyle="NONE" >
                <Label id="cloudFileDescription" text="{name}"/>
                <Label id="cloudFileLocation" text="{url}"/>
            </TableViewRow>
</Alloy>

controllers/cloudRow.js

var cloudRecordings = Alloy.createCollection('cloudRecordings');
if ($model) {
    $.cloudRow.model = $model.toJSON();
};

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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