开发者

How to set the same column width in a datagrid in flex at runtime?

开发者 https://www.devze.com 2022-12-22 19:06 出处:网络
HI, In flex, I have a datagrid with 22 columns. I initiall开发者_运维知识库y display all the columns. The width of each column right is uniform.

HI, In flex, I have a datagrid with 22 columns. I initiall开发者_运维知识库y display all the columns. The width of each column right is uniform. Now when i change the visiblity of a few columns, the width of each column varies. How do i maintain a uniform column width for each column whether or not there are any invisible columns?... Also how do i get the count of number of visible columns. the ColumnCount property returns total number of columns and not the number of visible ones.


The columns are an array, so you can append code to whatever function makes them invisible and loop through that array setting each ones width. You will just need to keep tabs on your Datagrids width, and the number of visible columns, which you can also do with a loop. Here's some untested code that should put you close to your goal:

function makeAColInvisible():void{
  //code you use to set col invisible

  var visColCount:number = 0;
  for each (var item:DataGridColumn in myDataGrid.columns){
    if(item.visible == true){
      visColCount++;
    }
  }

  for each (var item2:DataGridColumn in myDataGrid.columns){
    item2.width = myDataGrid.width / visColCount;
  }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号