1 Reply Latest reply on Jan 24, 2010 12:38 PM by atomUK

    Unable to drag drop from grid to tree

    atomUK

      Hi,

       

      I am ablel to drag but unable to drop to a grid.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" creationComplete="initVars()">
         
      <!--STEP 2 WRITE ACTION SCRIPT to populate data and perform action-->
      <mx:Script>
      <![CDATA[
          import mx.events.DropdownEvent;
          import mx.events.DragEvent;
      import mx.collections.XMLListCollection;
      import mx.controls.List;
      import mx.events.DataGridEvent;
      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      [Bindable]public var selectedcareplan: XMLList;
      [Bindable]public var selectedBCXML: XMLListCollection;
      [Bindable]public var businesscentertype: String;
      [Bindable]public var selectedBCPerformers: XMLList;
      [Bindable]public var selectedPerformerDetail: XMLList;                  
      [Bindable]public var originator: String;
      [Bindable]public var service: String;
      [Bindable]public var performer:String;
      [Bindable]public var dataFeedxml:XML;
      [Bindable]var careplans:XML ;
      [Bindable]var selectedplanproblem:String;
      [Bindable]var selectedplanname: String;
      [Bindable]var selectedplanid:String;
      [Bindable]var selectedplanresult: String;
      [Bindable]var selectedplansummary:String;
      [Bindable]var selectedplancomments:String;
                var xmltemplate: String = '';

       

      <!--STEP 3 write a function to populate data-->
      private function initVars():void
      {
      careplans = <careplanlist>
      <careplan id = '1' name = 'plan name 1' result = 'Good Health' comments = 'Good' summary = 'Here isthe a summary'>
          <issue>
          this is a problem
          </issue>
              <steps>
              <step id ='11' action = 'action1' output = 'out' outcome = 'outcome1'/>
              <step id ='12' action = 'action2' output = 'out' outcome = 'outcome2'/>
              <step id ='13' action = 'action3' output = 'out' outcome = 'outcome3'/>
              <step id ='14' action = 'action4' output = 'out' outcome = 'outcome4'/>
              </steps>
      </careplan>
      <careplan id = '2' name = 'plan name 2' result = 'Good Health2' comments = 'Good' summary = 'Here isthe a summary'>
          <issue>
          this is a problem
          </issue>
              <steps>
              <step id ='21' action = 'action21' output = 'out21' outcome = 'outcome21'/>
              <step id ='22' action = 'action22' output = 'out22' outcome = 'outcome22'/>
              <step id ='23' action = 'action23' output = 'out23' outcome = 'outcome23'/>
              <step id ='24' action = 'action24' output = 'out24' outcome = 'outcome24'/>
              </steps>               
      </careplan>                       
      </careplanlist>;

       

      //selectedBCXML = new XMLListCollection(selectedcareplan);
      //tree1.dataProvider = selectedBCXML;

       

      //Alert.show("Init Variables: Care plans = " + careplans, "Alert Box", Alert.OK);
      }

       

      private function ViewCarePlanDetail(event: Event):void
      {
      var careplanid: String;
      careplanid =  XML(DataGrid(event.currentTarget).selectedItem).@id;
      //            Alert.show("ViewCarePlanDetail = " + careplans, "Selected Care Plan", Alert.OK);
      selectedcareplan= careplans.careplan.(@id ==careplanid);
      Alert.show("ViewCarePlanDetail = " + selectedcareplan, "Selected Care Plan", Alert.OK);           
      //selectedBCXML = new XMLListCollection(selectedcareplan);
      selectedplanname = selectedcareplan.@name;
      selectedplanproblem = selectedcareplan.issue;
      selectedplanid = selectedcareplan.@id
      selectedplanresult = selectedcareplan.@result
      selectedplansummary = selectedcareplan.@summary
      selectedplancomments = selectedcareplan.@comments
      Alert.show("ViewCarePlanDetail = " + selectedplanname, "Selected Plan name", Alert.OK);
      }

       

      private function dragDropComplete(event: DragEvent):void
      {
      selectedBCXML = new XMLListCollection(selectedcareplan);
      //tree1.dataProvider = selectedBCXML;
      }

       


      private function treeLabel(item:Object):String
      {
      var node:XML = XML(item);
      if( node.localName() == "issue" )
        {return "Medical Issue: "+node.toString();}
      if( node.localName() == "careplan" )
         return "careplan: " +node.@name;
      if( node.localName() == "steps") return "steps:";
      if (node.localName()=="step") return "[ step : " + node.@id +"    action:   " + node.@action + "    output:   " + node.@output +  "   outcome:   " + node.@outcome +" ]";
      return null;
      }

       

      ]]>
      </mx:Script>
              
              
      <!-- STEP 1- Create data grid with columns and tree view-->
      <!-- to fill data grid columns with data, you need to bring in a DATA PROVIDER to provide data to columns-->
      <mx:VBox width="100%" height="100%" paddingTop="0">           
      <mx:Canvas width="100%" height="100%"   horizontalScrollPolicy="off"
          verticalScrollPolicy="off" cornerRadius="14" backgroundAlpha="0.28" backgroundColor="#C6ACAC" borderStyle="solid" borderColor="#EBF1F5" alpha="1.0">
             
      <!--<mx:TextInput x="11" y="22" width="252" editable="false" text="{selectedBC}" color="#800000" borderStyle="inset" cornerRadius="20" fontSize="11" fontFamily="Arial" fontWeight="bold"/> -->
      <!--dataProvider ="{careplans.careplan}"-->
      <mx:DataGrid id = "bcs" x="10" y="83" height="96" width="663" 
            fontFamily="Arial" fontSize="11" color="#352525" itemClick="ViewCarePlanDetail(event);"
            editable="false" enabled="true" fontWeight="bold"  cornerRadius="10" dragEnabled="true"
            dataProvider ="{careplans.careplan}" >
          <mx:columns>
          <mx:DataGridColumn headerText="Plan Name" dataField= "@id"/>   
          <mx:DataGridColumn headerText="Plan Id" dataField="@name"/>
          <mx:DataGridColumn headerText="Result" dataField="@result"/>
          <mx:DataGridColumn headerText="Comments" dataField="@comments"/>
          <mx:DataGridColumn headerText="Summary" dataField="@summary"/>
          </mx:columns>
      </mx:DataGrid>
             
      <mx:Label x="10" y="55" text="Available care plans" width="240" fontSize="11" fontFamily="Arial" fontWeight="bold" color="#7D4343"/>

       

      <!--dataProvider="{selectedBCXML}"-->
      <mx:Tree id="tree1"  labelFunction="treeLabel" showRoot="true"  width="761" height="132"  x="10" y="348"
             alpha="0.87" borderThickness="2"  fontFamily="Arial" fontSize="11" color="#121213"  cornerRadius="6"
             fontWeight="bold" enabled="true" dropEnabled="true"  dragDrop="dragDropComplete(event);"
             dataProvider="{selectedBCXML}"/>
       
      <mx:Label x="10" y="300" text="Selected Plan Details" width="192" fontSize="12" fontFamily="Arial" fontWeight="bold" color="#090808"/>
      <mx:Label x="10" y="196" text="Care plan name" width="95"/>
      <mx:Text x="115" y="196" width="135" text="{selectedplanname}" />
      <mx:Label x="283" y="196" text="Problem/Issue" width="77"/>
      <mx:Text x="400" y="196" width="140"  text="{selectedplanproblem}"/>
      <mx:Label x="10" y="222" text="Plan ID"/>
      <mx:Text x="115" y="222" width="135" text="{selectedplanid}" />
      <mx:Label x="283" y="235" text="Result"/>
      <mx:Text x="349" y="235" width="135" text="{selectedplanresult}" />
      <mx:Label x="10" y="258" text="Comments"/>
      <mx:Text x="100" y="258" width="150" text="{selectedplancomments}" />
      <mx:Label x="283" y="276" text="Summary"/>
      <mx:Text x="349" y="276" width="148" text="{selectedplansummary}" />
      </mx:Canvas>
      </mx:VBox>
      </mx:Canvas>
      <!-- end of STEP 1-->

       

      Help?