3 Replies Latest reply on Feb 15, 2008 10:50 PM by dlikhten

    Bug in DataGrid.as

    doug777 Level 1
      This function causes a problem because col contains the index of the column being resized and is the index of the columns array.

      On line 2379 it is used as the index of the visibleColumns array, which can be quite different from columns array.

      Anyone know how to get around this problem?

        • 1. Re: Bug in DataGrid.as
          I have been battling with this issue for quite some time now...
          I have tried the following:
          1) try resizing
          2) catch TypeError (if thrown)
          3) try using DataGrid.commitProperties()
          4) try resizing again.

          Unfortunately these steps help sometimes. Still a race condition problem it seems.

          Has anyone found a solution to this?

          The problem is: If a column was not previously visible and you need to set the width of that column (even after setting column.visible=true) flex will throw this exception because the column is not yet in the visibleColumns array of data grid.
          • 2. Re: Bug in DataGrid.as
            doug777 Level 1
            I vaguely remember getting round this problem by setting up different DataGrids each with its own set of visible columns and each on its own layer of a ViewStack. By applying the underlying array to each DataGrid thus: dgn.dataProvider = array.slice(); you can still manipulate each dataProvider's array without affecting them all.

            Now you can simply switch the ViewStack layer instead of changing the list of visible columns.

            One of the things that makes Flex so incredibly versatile and ultimately such a fantastic tool is its ability to get round problems since there are always so many different ways to effectively do the same thing. You just have to think creatively.

            Good luck,
            • 3. Re: Bug in DataGrid.as
              dlikhten Level 1
              Thanks, I'll try out different approaches. I have already considered many ways of forcing the DataGrid to update it's visible columns. I am going to do some heavy debugging and determine the right path. I am also trying to minimize memory usage so using multiple data grids can become problametic. However I see your point. Also what might work nicely is for the task i want to do (restore to defaults) I might wind up cloning all the columns and just swapping the data grid's entire columns array with a new one instead of trying to apply default preferences. (This is a data grid that remember's it's state).

              In any case, thanks for the advice.