DataGrid 동적으로 데이타 바인딩 - 1

Programming/Flex 2007.08.07 16:25 Posted by 파란크리스마스

xmldata.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<root>
  <msg>ok</msg>
  <pagemax>20</pagemax>
  <pageinx>1</pageinx>
  <data>
    <row>
      <aaa>1</aaa>
      <bbb>a</bbb>
    </row>
    <row>
      <aaa>2</aaa>
      <bbb>b</bbb>
    </row>
    <row>
      <aaa>3</aaa>
      <bbb>b</bbb>
    </row>
  </data>
</root>

borad2.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 creationComplete="xmlData1.send()">

 <mx:HTTPService id="xmlData1" url="http://localhost:8080/examples/xmldata.xml"/>

 <mx:DataGrid x="233" y="177" dataProvider="{xmlData1.lastResult.root.data.row}" width="457">
  <mx:columns>
   <mx:DataGridColumn headerText="Column 2" dataField="bbb"/>  
   <mx:DataGridColumn headerText="Column 1" dataField="aaa"/>
  </mx:columns>
 </mx:DataGrid>
 
</mx:Application>

신고

Flex DataGrid 동적으로 Column 생성하기 - 2

Programming/Flex 2007.08.03 14:15 Posted by 파란크리스마스

출처
http://flexdocs.kr/docs/flex2/langref/XMLList.html

http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=8&KEY=&SC=S&&CC=&PAGE=1&IDX=547


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="448">
 
  <mx:XMLList id="testlist">
    <column>
    <name>aaa</name>
   </column>
    <column>
    <name>bbb</name>
   </column>   
  </mx:XMLList>

  <mx:Script>
   <![CDATA[
    import mx.controls.dataGridClasses.DataGridColumn;
   
     private function createColumn():void
     {
      var columns : Array = grid1.columns;
      var tmpCol : DataGridColumn;
     
        var item:XML;
//        for (var i:uint=1; i<=testlist.length(); i++) {
        for each(item in testlist) {
         tmpCol =  new DataGridColumn();
        tmpCol.headerText = item.children().text();
        columns.push(tmpCol);  
        }
        
      grid1.columns = columns;
     }
    ]]>
  </mx:Script>
 
  <mx:DataGrid id="grid1" x="54" y="106" width="280" height="139"/>
 
  <mx:Button x="54" y="60" label="Button" click="{createColumn()}"/>

 
</mx:Application>

신고

Flex DataGrid 동적으로 Column 생성하기

Programming/Flex 2007.08.03 10:29 Posted by 파란크리스마스

출처
http://www.ihelpers.co.kr/programming/tipntech.php?CMD=view&TYPE=8&KEY=&SC=S&&CC=&PAGE=1&IDX=547

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="448">
  <mx:Script>
   import mx.controls.dataGridClasses.DataGridColumn;

    private function createColumn():void
    {
     var columns : Array = grid1.columns;
     var tmpCol :DataGridColumn =  new DataGridColumn();
     tmpCol.headerText = "Test";
     columns.push(tmpCol);
     
     grid1.columns = columns;
    }
  </mx:Script>
 
  <mx:DataGrid id="grid1" x="54" y="106" width="280" height="139"/>
 
  <mx:Button x="310" y="41" label="Button" click="{createColumn()}"/>
 
</mx:Application>

신고


 

티스토리 툴바