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?