0 Replies Latest reply on Aug 20, 2009 7:58 AM by RosieGp

    flex search

    RosieGp Level 1

      Hi,
      I have a question...  I have a Search button next to the textinput box...
      [
      Bindable] public var Emp:String;
      [
      Bindable] public var ary:Array = ["Emp name", "Emp number", "Emp id"];
      private function changeHandler(event:Event):void{
      Emp = String (cb.selectedItem);
      ti.text = String (cb.selectedItem);
      }
      <mx:ComboBox
      id="cb" dataProvider="{ary}" x="80" y="122" change="changeHandler(event)"></mx:ComboBox>
      <mx:TextInput id="ti" x="303" y="122"/>

      <mx:Button id="SearchBtn" label="Search" click="vs.selectedChild=vsEmployeeDetail"/>

      Now in "EmployeeDetail.mxml"
      I have the follwoing code...
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" x="0" y="0" width="1200" height="766" creationComplete="initEmpRef()" xmlns:src="*">
            <mx:Script>
            <![CDATA[
                  import mx.utils.ArrayUtil;
                        import mx.controls.Alert;
                        import mx.collections.ArrayCollection;
                        import mx.rpc.events.ResultEvent;
                        import mx.rpc.events.FaultEvent;
                        import mx.controls.dataGridClasses.DataGridColumn;
                       
                  [Bindable] public var RefDataProvider:ArrayCollection;
                       
                        private function initEmpRef():void {         
                              cf.getData();                
                        }
                  private function resultgetData(event:ResultEvent):void{
                        RefDataProvider = ArrayCollection(event.result);
                        if(RefDataProvider.toString()==''){Alert.show("No Data to Display");}
                  }                      
            ]]>
            </mx:Script>
           
            <!--Database Server Connection -->
            <mx:RemoteObject id="cf" destination="ColdFusion" source="Emp-debug.CFC.EmpRef" showBusyCursor="true">
              <mx:method name="getData" result="resultgetData(event)" fault="Alert.show(event.fault.message)"/>
          </mx:RemoteObject>       
                  <mx:DataGrid id="OrderGrid" dataProvider="{RefDataProvider}" left="10" right="10" bottom="60" top="10">
                        <mx:columns>     
                       <mx:DataGridColumn headerText="EMP NAME" dataField="EmpNameShort"/>    
                       <mx:DataGridColumn headerText="EMP #" dataField="EmpNumx"/>
                       <mx:DataGridColumn headerText="ADDRESS" width="80">
                        <mx:itemRenderer>
                        <mx:Component>
                                     <mx:Button color="#0276cd" label="Address" width="65" height="22" click="outerDocument.vsEmpRef.selectedChild=outerDocument.vsYHCPMS"/>
                        </mx:Component>
                               </mx:itemRenderer>
                           </mx:DataGridColumn>
                         <mx:DataGridColumn headerText="LAST UPDATED" dataField="LastDate"/>
                      </mx:columns>
                  </mx:DataGrid>
                   <mx:ViewStack id="vsEmpRef" left="0" right="20" bottom="10" top="62">       
            <mx:Canvas label="View 1" width="100%" height="100%">
                  </mx:Canvas>
                  <src:YHCPMS id="vsYHCPMS" width="100%" height="100%"/>
            </mx:ViewStack>  
      </mx:Canvas>

      1. Now my Search button should refer to vsEmployeeDetails right?????
      2. is it right to use creationComplete="initEmpRef()" ??
      3. I guess I need to put a cfargument for what ever the user may select as right now I'm hardcoding employee names... Do I add a loop according to what the user has entered in flex... my CFC looks like the following:

      <cfcomponent displayname="EmpRef.cfc" hint="CFC controls all things in EmpRef"  output="false">
      <cffunction name="getData" access="remote" returnType="query" output="false">
                  <cfset var DataQRY ="">
      <cfquery datasource="SQLserver" username="***" password="***" name="SQLQuery">
                                          select EmpDetail, EmpName
                                          from                       Employee
                                          Where EmpName='Andrew Hudson'
                              </cfquery>
      <cfquery datasource="Oracleserver" username="***" password="***" name="OracleQuery">
                                          select Emp_NUM, LastDate
                                          from    EmpInformation
                                          WHERE EmpName='Andrew Hudson'
                              </cfquery>
      <cfquery dbtype="query" name="DataQRY">
                                          select SQLQuery.EmpDetail, SQLQuery.EmpName, OracleQuery.LastDate
                                          from SQLQuery, OracleQuery
                                          Where SQLQuery.EmpDetail=OracleQuery.Emp_NUM
                                          </cfquery>
                  <cfreturn DataQRY>
                  </cffunction>
      </cfcomponent>


      I'll really appreciate your help...
      Thanks...