0 Replies Latest reply on May 11, 2011 11:33 PM by senthil s

    Flex List with data-grid issue any body can help me ......i added the full code below

    senthil s Level 1

      Exactly wat i want to do is

       

      1.if i click the open button want to visible all datagrid ,its working perfectly.

      2.if i click the close button want to close all data grid ,its working perfectly.

       

      3. if i click a particular  list means want to visible particular datagrid..some times working good but some times not visible ...

       

      4.if i click the list if datagrid already open means want to close .some times creates extra space below the datagrid........

       

      if u cont get clearly please copy the below code and check it.......and give the right solution for this problem.......

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"

      xmlns:s="library://ns.adobe.com/flex/spark"

      xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" >

       

      <fx:Declarations>

       

      </fx:Declarations>

       

      <fx:Script>

      <![CDATA[

      import mx.collections.ArrayCollection;

       

      [Bindable]

       

      public var ArrUserList:ArrayCollection;

      [Bindable]

      public var listDB:ArrayCollection = new ArrayCollection([ {label: "2011", data:"jan",day:"saturday",date:"1-4-11"},

      {label: "2011", data:"jan",day:"monday",date:"13-4-11"}, {label: "2013", data:"jan",day:"monday",date:"1-5-11"}, {label: "2013", data:"jan",day:"wednesday",date:"14-5-11"}, {label: "2015", data:"jan",day:"tuesday",date:"11-5-11"}, {label: "2015" ,data:"jan",day:"friday",date:"1-6-11"} ]);

       

      public var loc_first_last_name:String;

       

       

      function Load():void

      {

      ArrUserList=Find_Duplicate(listDB);

      for(var i:int=0; i<ArrUserList.length; i++)

      {

      ArrUserList[i].click=0;

      }

      Lst_userlist.dataProvider=ArrUserList;

      Lst_userlist.rowCount=ArrUserList.length;

       

      }

       

      function Clink_lnk_open():void

      {

       

      if(lnk_open.label=="Open")

      {

      for(var i:int=0; i<ArrUserList.length; i++)

      {

      ArrUserList[i].click=1;

      }

      lnk_open.label="Close";

      ArrUserList.refresh();

      Lst_userlist.validateNow();

      Lst_userlist.dataProvider=ArrUserList;

      Lst_userlist.rowCount = ArrUserList.length ;

       

      }

      else

      {

      for(var i:int=0; i<ArrUserList.length; i++)

      {

      ArrUserList[i].click=0;

      }

       

      lnk_open.label="Open";

      ArrUserList.refresh();

      Lst_userlist.validateNow();

      Lst_userlist.dataProvider=ArrUserList;

      Lst_userlist.rowCount = ArrUserList.length ;

      }

      }

       

      function Click_UserName1(event:MouseEvent,data:Object):void

      {

      loc_first_last_name=event.currentTarget.text;

      var str:String;

      for(var i:int=0; i<ArrUserList.length; i++)

      {

      str=ArrUserList[i].label;

       

      if(loc_first_last_name==str)

      {

      if(ArrUserList[i].click == 0)

      {

      ArrUserList[i].click=1;

      }

      else

      {

      ArrUserList[i].click=0;

      }

       

      }

      }

      ArrUserList.refresh();

      Lst_userlist.validateNow();

      Lst_userlist.dataProvider=ArrUserList;

      Lst_userlist.rowCount=ArrUserList.length;

       

      }

       

       

      public function Find_Duplicate(test_arr:ArrayCollection):ArrayCollection

      {

      var res_arr:ArrayCollection=new ArrayCollection();

      var flag:Boolean;

       

      for(var i:int=0;i<test_arr.length;i++)

      {

      var j:int=0

      flag=false;

      for(;j<res_arr.length;j++)

      {

      if(res_arr[j].label==test_arr[i].label)

      {

       

      res_arr[j].dataCollection.addItem(test_arr[i]);

      flag=true;

      break;

      }

      }

      if(!flag)

      {

       

      var myItem:Object = new Object() ;

      myItem.label=test_arr[i].label;

       

      myItem.dataCollection=new ArrayCollection();

       

      myItem.dataCollection.addItem(test_arr[i]);

      res_arr.addItem(myItem) ;

      }

      }

      return res_arr;

      }

       

       

       

      ]]>

      </fx:Script>

      <s:Scroller id="id_scroller" width="100%" height="100%">

       

      <s:VGroup id="id_Vgroup" paddingLeft="50" paddingTop="10" paddingBottom="10"   width="100%" height="100%" >

       

      <mx:VBox width="850" paddingLeft="0" paddingTop="1"    color="black"  backgroundColor="#FFFFFF">

       

       

       

      <mx:HBox width="850" left="50" paddingBottom="3"  paddingLeft="5" backgroundColor="#6D6C6C"   paddingTop="3" color="#FFFFFF" >

       

      <mx:LinkButton id="lnk_open" label="Open" textDecoration="underline" click="Clink_lnk_open();"/>

      <mx:Button id="load_btn" label="Load" click="Load()"/>

       

      </mx:HBox>

       

       

      <mx:VBox id="Vbox_main" width="850"   horizontalScrollPolicy="off" verticalScrollPolicy="off"  >

       

      <mx:List variableRowHeight="true"   width="850" id="Lst_userlist" paddingTop="-3" verticalScrollPolicy="off"  horizontalScrollPolicy="off" 

      buttonMode="true"  >

       

      <mx:itemRenderer>

       

      <fx:Component>

       

      <mx:VBox paddingTop="-5"  horizontalScrollPolicy="off" verticalScrollPolicy="off" >

       

      <fx:Script>

      <![CDATA[

      import mx.collections.ArrayCollection;

       

      override public function set data(value:Object):void

      {

      super.data = value;

      Membership_Grid.dataProvider=data.dataCollection;

       

       

      Membership_Grid.rowCount=data.dataCollection.length;

       

      lbl_userhead.text=data.label;

      lbl_userhead1.text=data.dataCollection.length+" Datas";

       

       

      if(data.click==1)

      {

      Vbox_main.visible=true;

      Vbox_main.includeInLayout=true;

      }

      else

      {

      Vbox_main.visible=false;

      Vbox_main.includeInLayout=false;

      }

      Membership_Grid.validateNow() ;

      }

       

       

      ]]>

       

      </fx:Script>

       

      <mx:HBox id="vbox_grid"  horizontalScrollPolicy="off"  height="25" verticalScrollPolicy="off" width="850"  paddingLeft="10" paddingTop="5"  backgroundColor="#6D6C6C" color="#FFFFFF">

       

      <s:Label id="lbl_userhead" click="outerDocument.Click_UserName1(event,data)" buttonMode="true"   width="250"  paddingTop="3" />

      <s:Label id="lbl_userhead1"  buttonMode="true"   width="548" paddingTop="3" />

       

      </mx:HBox>

       

      <mx:VBox id="Vbox_main" width="850" horizontalScrollPolicy="off" verticalScrollPolicy="off"  visible="false" includeInLayout="false" >

       

      <mx:DataGrid id="Membership_Grid"   alternatingItemColors="[#DCDCDC,#F8F8FF]"  paddingLeft="5"  horizontalScrollPolicy="off" color="black"

      horizontalGridLines="false" verticalScrollPolicy="auto"  verticalGridLines="false"  rowHeight="25" width="850"  borderSkin="{null}" 

      borderVisible="false" >

       

      <mx:columns>

       

      <mx:DataGridColumn width="150" headerText="Year" dataField="label"/>

       

      <mx:DataGridColumn width="150" headerText="Month" dataField="data"/>

       

      <mx:DataGridColumn width="150" headerText="Day" dataField="day" />

       

      <mx:DataGridColumn width="150" headerText="Date"  dataField="date"/>

       

      </mx:columns>

       

      </mx:DataGrid>

       

      </mx:VBox>

       

      </mx:VBox>

       

      </fx:Component>

       

      </mx:itemRenderer>

       

      </mx:List>

       

      </mx:VBox>

       

      </mx:VBox>

       

      </s:VGroup>

       

      </s:Scroller>

       

      </s:Group>

      Thanks in advance ,
      senthil.