0

我在高级数据网格中有组合框,我希望当用户单击当前列时,该列变宽,当用户获取另一列时执行相同的操作,而前一个列在失去焦点时获得默认值

我正在阅读'bout focusIn但我找不到一个很好的例子......

有人,有什么想法吗?

4

1 回答 1

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;
                }
            }

        }
于 2013-08-29T22:11:15.183 回答