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

Passing model data from table to detail controller

$
0
0

I have a fairly simple Alloy app that gets data from a server and puts it in a collection, which is then displayed in a TableView. That all works fine, but now I need to implement the detail controller which obviously opens up a new window on clicking one of the rows to show more detailed information.

The main view looks something like this:

<Alloy>
    <Collection src="project" />
    <Window id="projectsWin" class="container" title="My projects">
 
        <TableView dataCollection="project">
            <TableViewRow hasChild="true" onClick="viewProject">
                <View class="projectRow">
                    <Label class="projectId" text="{project_id}" />
                    <Label class="projectClient" text="{client_name}" />
                    <Label class="projectAddress" text="{address}" />
                </View>
            </TableViewRow>
        </TableView>
 
    </Window>
</Alloy>
And in the controller:
function viewProject(e) {
 
    Alloy.createController('detail', {
        project_id: e.row.children[0].children[0].text,
        client_name: e.row.children[0].children[1].text,
        address: e.row.children[0].children[2].text
    }).getView().open();
 
}
The function obviously sends the values of the text properties of the labels to the detail controller, but it seems like a very poor way to do it.

Is it possible to instead send a reference to the model as the single argument to the controller so that the data can be retrieved from the database rather than being sent directly from the main controller?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



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