Hi,

It is all working great now.  I am using ColdFusion and once I used CAPS for the columnNames in the dataField="FIRSTNAME" as opposed to "firstname" it works beautifully.  Thanks for all the tips as well.  It really helps.  I think once I get the foundation and the ability to do things that I have been doing in ColdFusion then I am well on my way. This stuff is really cool.

-Malik


--- In flexcoders@yahoogroups.com, "Tim Hoff" <[EMAIL PROTECTED]> wrote:
>
>
> Hi Malik,
>
> Glad to help. Here are a couple of answers to your questions.
>
> >What is "lastResult". Where does that come from and how
> >would one know about this?
>
> lastResult is the ActionScript object that is returned from an RPC call.
> The name was changed from result to lastResult to distinguish it from
> the result of an event. You can search the help docs for lastResult to
> learn more.
>
> >Any idea why I do not see any actual text in the grid? I tried
> >firstname, FIRSTNAME, as I heard someone reference that I need to use
> >CAPS, but either way I do not get values in the grid. But it does
> >appear records are there as I move the mouse over, it highlights the
> >*would be value*.
>
> The field names of your lastResult object are case sensitive. They need
> to match the field names in your query exactly. In this case firstname
> and lastname.
>
> > I removed the "send()" and it still worked so I am not sure of the
> > reason for it? Is is a coding practice to use that, either way it
> > worked with and without the send() method call.
>
> Yes, this is a common coding practice. It helps you and other
> programmers read the code quickly to see when the data service is being
> called.
>
> > How would you reference an array? Lets say I had a CFC that returned
> > like a 2D array?
>
> Another common practice is to cast the lastResult from a service call to
> an ArrayCollection or an XMLListCollection. These objects can be easily
> accessed, manipulated (filter, sort...) and bound to list-based controls
> (DataGrid, Tree...). The members of the ArrayCollection can be
> accessed with dot notations like: contactsAC.phoneNumbers.homePhone. It
> is also common to use onResult and onFault event listener functions
> with RPC calls. But, let's take this one step at a time. See the
> example below.
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> <http://www.adobe.com/2006/mxml> "
> layout="absolute" creationComplete="initApp()">
>
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> import mx.utils.ArrayUtil;
> import mx.rpc.events.*;
>
> public function initApp():void {
> // Force artists class to load
> artSvc.getArtists.send();
> }
> ]]>
> </mx:Script>
>
> <mx:RemoteObject id="artSvc" destination="ColdFusion"
> source="myapp.cf.com.artists" showBusyCursor="true" />
>
> <mx:ArrayCollection id="artistsAC"
> source="mx.utils.ArrayUtil.toArray(artSvc.getArtists.lastResult)"/>
>
> <mx:DataGrid id="dgArtists" dataProvider="{artistsAC}" x="177" y="65">
> <mx:columns>
> <mx:DataGridColumn headerText="First Name" dataField="firstname"/>
> <mx:DataGridColumn headerText="Last Name" dataField="lastname"/>
> </mx:columns>
> </mx:DataGrid>
>
> </mx:Application>
>
> Hope that this helps,
> -TH
>
> --- In flexcoders@yahoogroups.com, "malik_robinson" Malik_Robinson@
> wrote:
> >
> >
> > Hi,
> >
> > Sweet it is working now. The "lastResult" worked. So that is
> > basically a reference to my query object?
> >
> > Once I did that, just for tests I removed the :
> >
> > public function initApp():void {
> > // Force artists class to load
> > artSvc.getArtists.send();
> > }
> >
> > I removed the "send()" and it still worked so I am not sure of the
> > reason for it? Is is a coding practice to use that, either way it
> > worked with and without the send() method call.
> >
> > How would you reference an array? Lets say I had a CFC that returned
> > like a 2D array?
> >
> > I guess I really looking for more information on how a datagrid or
> tree
> > control or whatever it may be would handle things of different data
> > types like an array or a query object or whatever.
> >
> > Thanks for the help! Highly appreciated!
> >
> > -Malik
> >
> >
> >
> >
> > --- In flexcoders@yahoogroups.com, "Tim Hoff" TimHoff@ wrote:
> > >
> > > Yeah,
> > >
> > > Sorry, use:
> > >
> > > artSvc.getArtists.lastResult
> > >
> > > for the dataProvider, without artists at the end.
> > >
> > > -TH
> > >
> > > --- In flexcoders@yahoogroups.com, "malik_robinson"
> > > Malik_Robinson@ wrote:
> > > >
> > > >
> > > > Hi,
> > > >
> > > > I ended up getting an error, I think it was due to the text
> > > > "lastResult". Below is the error:
> > > >
> > > > I am very curious to know if someone can try this simple example
> > > and get
> > > > a datagrid to populate via a query object from CF.
> > > >
> > > > Error: Unknown Property 'artists'.
> > > > at
> > > >
> > >
> mx.collections::ListCollectionView/http://www.adobe.com/2006/actionsc
> > > rip\
> > > > t/flash/proxy::getProperty()
> > > > at mx.binding::PropertyWatcher/::updateProperty()
> > > > at mx.binding::Watcher/mx.binding:Watcher::wrapUpdate()
> > > > at mx.binding::PropertyWatcher/updateParent()
> > > > at mx.binding::Watcher/updateChildren()
> > > > at mx.binding::PropertyWatcher/::updateProperty()
> > > > at mx.binding::Watcher/mx.binding:Watcher::wrapUpdate()
> > > > at mx.binding::PropertyWatcher/eventHandler()
> > > > at flash.events::EventDispatcher/dispatchEvent()
> > > > at
> > > >
> > >
> mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::r
> > > esu\
> > > > ltHandler()
> > > > at mx.rpc::Responder/result()
> > > > at mx.rpc::AsyncRequest/acknowledge()
> > > > at
> > > >
> ::NetConnectionMessageResponder/NetConnectionChannel.as$42:NetConne
> > > ction\
> > > > MessageResponder::resultHandler()
> > > > at mx.messaging::MessageResponder/result()
> > > >
> > > >
> > > > Here is the CFC:
> > > >
> > > > <cfcomponent>
> > > >
> > > >
> > > >
> > > > <cffunction name="getArtists" access="remote" returntype="query">
> > > >
> > > > <cfset var artists = '' />
> > > >
> > > > <cfquery name="Artists" datasource="cfcodeexplorer">
> > > >
> > > > SELECT firstname, lastname
> > > >
> > > > FROM ARTISTS
> > > >
> > > > </cfquery>
> > > >
> > > > <cfreturn Artists />
> > > >
> > > > </cffunction>
> > > >
> > > > </cfcomponent>
> > > >
> > > > Here is the current MXML:
> > > >
> > > > <?xml version="1.0" encoding="utf-8"?>
> > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> > > > <http://www.adobe.com/2006/mxml> " layout="absolute"
> > > > creationComplete="initApp()">
> > > >
> > > > <mx:Script>
> > > > <![CDATA[
> > > > import mx.rpc.events.*;
> > > > import mx.collections.ArrayCollection;
> > > >
> > > >
> > > > public function initApp():void {
> > > > // Force artists class to load
> > > > artSvc.getArtists.send();
> > > > }
> > > >
> > > > ]]>
> > > > </mx:Script>
> > > >
> > > > <mx:RemoteObject
> > > > id="artSvc"
> > > > destination="ColdFusion"
> > > > source="myApp.cf.com.artists"
> > > > showBusyCursor="true" />
> > > >
> > > >
> > > > <mx:DataGrid id="dg" dataProvider="{artSvc.getArtists.artists}"
> > > x="177"
> > > > y="65">
> > > > <mx:columns>
> > > > <mx:DataGridColumn headerText="First Name"
> > > dataField="firstName"/>
> > > > <mx:DataGridColumn headerText="Last Name"
> > > dataField="lastName"/>
> > > > </mx:columns>
> > > > </mx:DataGrid>
> > > >
> > > > </mx:Application>
> > > >
> > > >
> > > >
> > > > --- In flexcoders@yahoogroups.com, "Tim Hoff" <TimHoff@> wrote:
> > > > >
> > > > >
> > > > > Hi Malik,
> > > > >
> > > > > I can't test this, but this is how the examples that I've seen
> > > work.
> > > > >
> > > > > -TH
> > > > >
> > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
> > > > > <http://www.adobe.com/2006/mxml> "
> > > > > layout="absolute" creationComplete="initApp()">
> > > > >
> > > > > <mx:Script>
> > > > > <![CDATA[
> > > > > import mx.collections.ArrayCollection;
> > > > > import mx.rpc.events.*;
> > > > >
> > > > > public function initApp():void {
> > > > > // Force artists class to load
> > > > > artSvc.getArtists.send();
> > > > > }
> > > > > ]]>
> > > > > </mx:Script>
> > > > >
> > > > > <mx:RemoteObject id="artSvc" destination="ColdFusion"
> > > > > source="myapp.cf.com.artists" showBusyCursor="true" />
> > > > >
> > > > > <mx:DataGrid id="dgArtists"
> > > > > dataProvider="{artSvc.getArtists.lastResult.artists}" x="177"
> > > y="65">
> > > > > <mx:columns>
> > > > > <mx:DataGridColumn headerText="First Name"
> > > dataField="firstname"/>
> > > > > <mx:DataGridColumn headerText="Last Name" dataField="lastname"/>
> > > > > </mx:columns>
> > > > > </mx:DataGrid>
> > > > >
> > > > > </mx:Application>
> > > > >
> > > > > --- In flexcoders@yahoogroups.com, "malik_robinson"
> > > Malik_Robinson@
> > > > > wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I have the following code that I *thought* would work, but it
> > > does
> > > > > > not. Can anyone see why this might not work? Basically the
> > > datagrid
> > > > > > does not get loaded, the browser says "transferring data from
> > > > > > localhost", but it never populates the grid, no error, I see
> > > the
> > > > show
> > > > > > busy cursor and my empty datagrid. I am using CF 7 and there
> > > is a
> > > > > > datasource that is defined when you install the tutorials. It
> > > is
> > > > > > basically a database of artists or something. I wrote a test
> > > page to
> > > > > > ensure my CFC works and it does return a query object, so I
> > > know the
> > > > > > CFC is fine.
> > > > > >
> > > > > > I am just trying to have it load the datagrid upon
> > > creationComplete
> > > > > >
> > > > > > Here is the main.mxml:
> > > > > >
> > > > > > <?xml version="1.0" encoding="utf-8"?>
> > > > > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> > > > > > layout="absolute" creationComplete="initApp()">
> > > > > >
> > > > > > <mx:Script>
> > > > > > <![CDATA[
> > > > > > import mx.collections.ArrayCollection;
> > > > > > import mx.rpc.events.*;
> > > > > >
> > > > > >
> > > > > > public function initApp():void {
> > > > > > // Force artists class to load
> > > > > > artSvc.getArtists();
> > > > > > }
> > > > > > ]]>
> > > > > > </mx:Script>
> > > > > >
> > > > > > <mx:RemoteObject id="artSvc" destination="ColdFusion"
> > > > > > source="myapp.cf.com.artists" showBusyCursor="true" />
> > > > > >
> > > > > > <mx:DataGrid id="dgArtists"
> > > > > > dataProvider="{artSvc.getArtists.artists}" x="177" y="65">
> > > > > > <mx:columns>
> > > > > > <mx:DataGridColumn headerText="First Name"
> > > > > > dataField="firstname"/>
> > > > > > <mx:DataGridColumn headerText="Last Name"
> > > > > > dataField="lastname"/>
> > > > > > </mx:columns>
> > > > > > </mx:DataGrid>
> > > > > >
> > > > > >
> > > > > > </mx:Application>
> > > > > >
> > > > > >
> > > > > > Any ideas?
> > > > > >
> > > > > > -Malik
> > > > > >
> > > > >
> > > >
> > >
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to