【问题标题】:update column width advanceddatagird on focus in FLEX?在 FLEX 中更新列宽高级数据网格?
【发布时间】:2013-09-02 06:46:27
【问题描述】:

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

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

有人有什么想法吗?

【问题讨论】:

    标签: apache-flex combobox focus advanceddatagrid


    【解决方案1】:

    好吧,我可以告诉您如何调整已单击项目的列的大小。我确信有一种更简单的方法可以做到这一点......

    给你的数据网格一个项目点击事件:

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

    【讨论】:

    • 太棒了!事实上,我找到了其他使用 mouseover 和 mouseout 的解决方案,就像 protected function combobox3_mouseOverHandler(event:MouseEvent):void { // TODO Auto-generated method stub outerDocument.theid.width = 200; } 一样简单,但你的回答帮助我调整了宽度......谢谢你的时间。!
    猜你喜欢
    • 2010-12-23
    • 1970-01-01
    • 1970-01-01
    • 2010-12-24
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    • 1970-01-01
    • 2013-10-23
    相关资源
    最近更新 更多