Forum: Ruby on Rails RubyAmf + DataGrid Binding

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Enzo R. (Guest)
on 2009-03-05 14:01
Hi there!

I'm trying to bind some data from my Rails application inside a Flex
Datagrid, and i'm just wondering why this code don't work!

flex Code:

  <![CDATA[
    import mx.collections.ArrayCollection;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.Fault;
    import mx.rpc.AsyncToken;
    import mx.rpc.remoting.RemoteObject;


    private function load(e:Event):void{
      var ro:RemoteObject = new RemoteObject();
      ro.source="StoreController";
      ro.destination = "rubyamf";
      ro.retrieveProducts();
      ro.addEventListener(ResultEvent.RESULT,onResult);
      ro.addEventListener(FaultEvent.FAULT,onFault);
    }
    private function onFault(e:FaultEvent):void
    {
      resultTxt.text = e.fault.faultString;
    }

    private function onResult(event:ResultEvent):void
    {
      dg.dataProvider = event.result
    }

  ]]>
</mx:Script>

  <mx:DataGrid id="dg" width="600" height="400">
    <mx:columns>
      <mx:DataGridColumn dataField="id"/>
    </mx:columns>
  </mx:DataGrid>
<mx:Panel width="600" height="400" x="610" id="productPanel"
title="Prodotti">
  <mx:Label id="resultTxt" />
  <mx:Button label="Align" click="load(event)" />
   </mx:Panel>

StoreController Code

  def retrieveProducts
    respond_to do |format|
      format html
      format.amf {render :amf => Product.find(:all) }
      format.xml {render :xml => Product.find(:all) }
    end
  end

from the console i see that the application retrieve the data, but the
Datagrid remains empty! :-(

some word on this?

thanks a lot in advance!

enzo rivello
Enzo R. (Guest)
on 2009-03-05 14:07
Update:

actually it load the data
the problem is that the data remains invisible!
someone can explain me why?
This topic is locked and can not be replied to.