Custom Component dataProvider
here's code have far:
main application file:
<?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="components.*">
<mx:script>
<![cdata[
import mx.rpc.events.*;
import mx.collections.arraycollection;
import mx.rpc.events.resultevent;
import mx.events.*;
[bindable]
public var customers:arraycollection = null;
public function customersrpcresult(event:resultevent):void
{
customers = new arraycollection();
customers = event.result.customers.person arraycollection;
}
public function customersrpcfaulthandler(event:faultevent):void
{
}
]]>
</mx:script>
<!--customers.php - provides xml data customers:arraycollection-->
<mx:httpservice id="customersrpc" url="assets/customers.php" result="customersrpcresult(event)" fault="customersrpcfaulthandler(event)" />
<comp:customerinfo creationcomplete="customersrpc.send()" customerinfo.dataprovider="{customers}" />
</mx:application>
customerinfo.mxml - component i'm trying set dataprovider of datagrid for
<?xml version="1.0" encoding="utf-8"?>
<mx:vbox xmlns:mx=" http://www.adobe.com/2006/mxml">
<mx:hbox width="100%" height="34">
<mx:label text="filter data"/>
<mx:textinput id="customerfiltertext"/>
<mx:button label="clear"/>
<mx:button label="refresh"/>
</mx:hbox>
<mx:hbox width="100%" height="100%">
<mx:datagrid width="100%" height="197" id="customerinfo">
<mx:columns>
<mx:datagridcolumn headertext="last" datafield="last"/>
<mx:datagridcolumn headertext="first" datafield="first"/>
<mx:datagridcolumn headertext="home" datafield="home"/>
</mx:columns>
</mx:datagrid>
</mx:hbox>
</mx:vbox>
main application file:
<?xml version="1.0" encoding="utf-8"?>
<mx:application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="components.*">
<mx:script>
<![cdata[
import mx.rpc.events.*;
import mx.collections.arraycollection;
import mx.rpc.events.resultevent;
import mx.events.*;
[bindable]
public var customers:arraycollection = null;
public function customersrpcresult(event:resultevent):void
{
customers = new arraycollection();
customers = event.result.customers.person arraycollection;
}
public function customersrpcfaulthandler(event:faultevent):void
{
}
]]>
</mx:script>
<!--customers.php - provides xml data customers:arraycollection-->
<mx:httpservice id="customersrpc" url="assets/customers.php" result="customersrpcresult(event)" fault="customersrpcfaulthandler(event)" />
<comp:customerinfo creationcomplete="customersrpc.send()" customerinfo.dataprovider="{customers}" />
</mx:application>
customerinfo.mxml - component i'm trying set dataprovider of datagrid for
<?xml version="1.0" encoding="utf-8"?>
<mx:vbox xmlns:mx=" http://www.adobe.com/2006/mxml">
<mx:hbox width="100%" height="34">
<mx:label text="filter data"/>
<mx:textinput id="customerfiltertext"/>
<mx:button label="clear"/>
<mx:button label="refresh"/>
</mx:hbox>
<mx:hbox width="100%" height="100%">
<mx:datagrid width="100%" height="197" id="customerinfo">
<mx:columns>
<mx:datagridcolumn headertext="last" datafield="last"/>
<mx:datagridcolumn headertext="first" datafield="first"/>
<mx:datagridcolumn headertext="home" datafield="home"/>
</mx:columns>
</mx:datagrid>
</mx:hbox>
</mx:vbox>
your custom component based on vbox has no dataprovider attribute set. i'm assuming wish set dataprovider datagrid, customerinfo. you'll need add script custom component provide function.
More discussions in Flex (Read Only)
adobe
Comments
Post a Comment