Guest User

erro filtro datagrid

a guest
Jul 5th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
  3.                     xmlns:s="library://ns.adobe.com/flex/spark"
  4.                     xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"
  5.                     creationComplete="init(event)" title="Lista de Clientes" close="{PopUpManager.removePopUp(this)}">
  6.    
  7.     <fx:Declarations>
  8.         <s:RemoteObject id="roClientes"
  9.                         source="ClienteController"
  10.                         destination="zend"
  11.                         endpoint="http://programapedido.com.br/php/gateway.php"
  12.                         fault="onFaultResult(event)"
  13.                         showBusyCursor="true">
  14.                
  15.             <s:method name="listar" result="onListarResult(event)" >
  16.                
  17.             </s:method>
  18.            
  19.         </s:RemoteObject>
  20.        
  21.     </fx:Declarations>
  22.    
  23.     <fx:Script>
  24.         <![CDATA[
  25.             import mx.collections.ArrayCollection;
  26.             import mx.controls.Alert;
  27.             import mx.events.FlexEvent;
  28.             import mx.managers.PopUpManager;
  29.             import mx.rpc.events.FaultEvent;
  30.             import mx.rpc.events.ResultEvent;
  31.            
  32.             //Variaveis
  33.             [Bindable]
  34.             public var lista:ArrayCollection;
  35.            
  36.             protected function init(event:FlexEvent):void
  37.             {
  38.                 roClientes.listar();
  39.             }
  40.  
  41.             protected function onListarResult(event:ResultEvent):void
  42.             {              
  43.                 lista = new ArrayCollection(event.result as Array);
  44.                 lista.filterFunction = buscaClientes;
  45.                 lista.refresh();
  46.             }
  47.            
  48.             protected function onFaultResult(event:FaultEvent):void
  49.             {
  50.                 Alert.show('Erro');        
  51.             }
  52.            
  53.             private function buscaClientes(item:Object):Boolean {
  54.                 if (item.nome.toLowerCase().search(txtProcurar.text.toLowerCase()) != -1)
  55.                     return true;
  56.                 else
  57.                     return false;
  58.             }
  59.            
  60.                        
  61.         ]]>
  62.     </fx:Script>
  63.    
  64.     <s:Group y="10" width="800" height="600" horizontalCenter="0"
  65.              verticalCenter="0">
  66.        
  67.         <s:layout>
  68.             <s:VerticalLayout />
  69.         </s:layout>
  70.        
  71.         <s:Group x="15" y="25" width="100%" height="41">
  72.             <s:layout>
  73.                 <s:HorizontalLayout paddingLeft="10" paddingTop="15"/>
  74.             </s:layout>
  75.            
  76.             <s:Label text="Procurar por nome" fontWeight="bold" paddingTop="6"/>
  77.             <s:TextInput id="txtProcurar" width="240" change="{lista.refresh()}" />
  78.             <s:Button id="btnProcurar" label="Procurar" />
  79.            
  80.         </s:Group>
  81.        
  82.         <s:DataGrid id="dataGrid" dataProvider="{lista}" width="100%" height="100%" requestedRowCount="4">         
  83.             <s:columns>
  84.                 <s:ArrayList>
  85.                     <s:GridColumn dataField="codigo" headerText="Código"></s:GridColumn>
  86.                     <s:GridColumn dataField="nome" headerText="Nome"></s:GridColumn>
  87.                     <s:GridColumn dataField="foneRes" headerText="Telefone"></s:GridColumn>
  88.                     <s:GridColumn dataField="foneCel" headerText="Celular"></s:GridColumn>
  89.                     <s:GridColumn dataField="email" headerText="Email"></s:GridColumn>
  90.                 </s:ArrayList>
  91.             </s:columns>           
  92.         </s:DataGrid>
  93.        
  94.        
  95.     </s:Group>
  96.    
  97. </s:TitleWindow>
Advertisement
Add Comment
Please, Sign In to add comment