Tuesday, March 13, 2007

Issues with DataGrid Column Visibility

A friend of mine passed along an interesting problem regarding DataGrids. They had the need to hide certain columns and then dynamically load the data. When doing this as expected, such as dataGridName.dataProvider = yourArrayName, the hidden columns would not stay hidden. The workaround to this issue is to track the visibility of each DataGridColumn, set the column to visible, and then override it with the visibility status we stored.

View the example here and download the code here.

Definately not optimal, but it works... ;-)

3 comments:

  1. Jon Lachelt1:19 PM

    Thanks Michael, I've noticed the same problem and have been looking for a work-around (and some understanding of why this is the case, seems like a defect to me). I'll try your solution.

    ReplyDelete
  2. Anonymous5:35 AM

    well, even after downloading the hotfix, the problem was still there, so I found a solution ...
    just set width="0" for the column you don't want to be visible ...

    ReplyDelete
  3. Anonymous11:46 AM

    but if the columns are resizable, setting the width to 0 will not help because if the user resized the column, the hidden column would appear

    ReplyDelete