问题
After executing a navigator.pushView with data object, I'm in need of the data object to be received into the next view, but at some stage transformed into a string to use in a sql function. The code below shows what I'm working on at the moment.
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="{data.toString()}"
xmlns:model="model.*"
creationComplete = "{data=srv.findByCategory(data.toString())}"
>
.toString() was my quick attempt at it, but the resultant output is simply
[object Object]
There aren't any errors but it only shows during debug.
Any ideas?
As appendage, here is the code from the initial view where the data object originates from
<s:List id="list" top="0" bottom="0" left="0" right="0" width="100%"
alternatingItemColors="0xffffff"
contentBackgroundColor="0xffffff"
downColor="0xfc7d1a"
selectionColor="0xfc7d1a"
dataProvider="{data}"
labelFunction="getFullName"
change="navigator.pushView(CategoryView, list.selectedItem.toString())">
And here is some of the code which needs the data object to be a String.
public function findByCategory(searchKey:String):ArrayCollection
{
}
回答1:
data is a keyed object containing containing the info you passed from the initial view. You need to access the correct key in your object.
It should be something like data.myKey.toString()
. I would be able to tell you exactly if you paste your pushView code.
来源:https://stackoverflow.com/questions/10483027/flex-pushview-data-object-being-converted-into-a-string