2013-08-29 29 views
0

我有一個高級數據庫中的組合框,我希望當用戶點擊當前列時,列變寬,當用戶得到另一列時相同,前一個失去焦點時得到默認值在FLEX中更新列寬advanceddatagird on focus?

我在閱讀'布特focusIn但我找不到一個很好的例子...

有沒有人,任何想法?

回答

0

那麼我可以告訴你如何調整項目被點擊的列的大小。我敢肯定有一個更簡單的方法來做到這一點...

給您的數據網格中的項目單擊事件:

<mx:AdvancedDataGrid 
    name="datagrid" 
    id="datagrid" 
    width="50%" 
    columns="{columnsArr}" 
    dataProvider="{dataProv}" 
    itemClick="resizeCol(event)" 
    /> 

public function resizeCol(event:ListEvent):void 
     { 
      //The new width for the column which has been clicked 
      var newColumnWidth:Number = 300; 
      //Calculate the width to resize the other columns to; width of the datagrid 
      //divided by how many columns are in the DG (minus the one we are resizing) 
      //Then, subtracted by half the width of the column we are resizing 
      var equalColWidth:Number = Math.floor(this.datagrid.width/(this.datagrid.columns.length -1)); 
      equalColWidth -= (newColumnWidth/2); 
      //Grab the column to resize from the event object 
      var column:AdvancedDataGridColumn = this.datagrid.columns[event.columnIndex] as AdvancedDataGridColumn; 

      //Loop columns, make the column which will change to the new width, 
      //Make the other columns equal in size. 
      for each(var col:AdvancedDataGridColumn in this.datagrid.columns) 
      { 
       if(col == column) 
       { 
        column.width = newColumnWidth; 
       } 
       else 
       { 
        col.width = equalColWidth; 
       } 
      } 

     } 
+0

真棒!事實上,我發現使用鼠標懸停和鼠標移開, 如 '保護的函數combobox3_mouseOverHandler一樣簡單(事件:MouseEvent)方法:其他溶液空隙 \t \t \t \t \t \t \t \t \t { \t \t \t \t \t \t \t \t \t \t // TODO自動生成方法存根 \t \t \t \t \t \t \t \t \t \t outerDocument.theid.width = 200; \t \t \t \t \t \t \t \t \t}' 但你的回答讓我調整寬度... 感謝您的時間的人! – jompi