Even columns with visible=false get instantiated when declared in MXML.

On 10/10/11 3:36 AM, "bhaq1972" <mbha...@hotmail.com> wrote:






Yes agreed. In our newer applications we do that.

Just curious, if a column is defined as visible=false in mxml. That wouldn't be 
a memory consumption would it?

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
"valdhor" <valdhorlists@...> wrote:
>
> If that is the use case I would have built that data grid and columns on the 
> fly in ActionScript. Why bother having columns in memory that you don't use?
>
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> "bhaq1972" <mbhaque@> wrote:
> >
> > The problem doesn't exist if the code is executed in the preintialize or 
> > creationComplete event. However, I didn't want to mention that because it 
> > takes the focus away from what looks like a bug in initialize. Why would 
> > one column give a runtime error and the other not?
> > Halo datagrid doesnt have this problem.
> >
> > In our scenario, some columns have no relevance to certain customers. 
> > Instead of removing the column from the mxml, we store the column info (in 
> > this case make invisible) in the database.
> > During the datagrid initialze we make it invisible. The creationcomplete 
> > event would be too late because by then the column would have rendered (for 
> > a split second).
> >
> > Preinitialize would be ok...but other parts of my code (unrelated to this 
> > problem) are failing because preinitialize is too early. i can't bare any 
> > more code rewrites(but i suppose it keeps me in a job).
> >
> >
> >
> >
> > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> > "valdhor" <valdhorlists@> wrote:
> > >
> > > The column probably hasn't been created yet. Try the creationcomplete 
> > > event of the datagrid.
> > >
> > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
> > > "bhaq1972" <mbhaque@> wrote:
> > > >
> > > > I get a runtime error when I set the gridcolumn.visible property during 
> > > > a datagrid initialize event. There is no problem's
> > > > if its the first gridcolumn. Looks like a bug?
> > > >
> > > > Can anyone suggest a workaround?
> > > >
> > > >
> > > > <s:DataGrid initialize="makeColumnInvisible()">
> > > >   <s:columns>
> > > >     <s:ArrayList>
> > > > <s:GridColumn id="gc0" dataField="col0" headerText="col0"/>
> > > > <s:GridColumn id="gc1" dataField="col1" headerText="col0"/>
> > > >
> > > > ..
> > > > public function makeColumnInvisible():void
> > > > {
> > > >    gc1.visible = false;  // causes a RTE
> > > >    gc0.visible = false;  // doesnt give a problem
> > > > ..
> > > >
> > > >
> > > > RangeError: Error #1125: The index 1 is out of range 0.
> > > > at 
> > > > spark.components.gridClasses::GridDimensions/setTypicalCellWidth()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\gridClasses\GridDimensions.as:1325]
> > > > at 
> > > > spark.components.gridClasses::GridDimensions/columns_visibleChangedHandler()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\gridClasses\GridDimensions.as:1840]
> > > > at 
> > > > spark.components.gridClasses::GridDimensions/columnsCollectionChanged()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\gridClasses\GridDimensions.as:1800]
> > > > at 
> > > > spark.components::Grid/columns_collectionChangeHandler()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\Grid.as:4429]
> > > > at flash.events::EventDispatcher/dispatchEventFunction()
> > > > at flash.events::EventDispatcher/dispatchEvent()
> > > > at spark.components.gridClasses::GridColumn/set 
> > > > visible()[E:\dev\hero_private\frameworks\projects\spark\src\spark\components\gridClasses\GridColumn.as:1564]
> > > > ...
> > > >
> > >
> >
>






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to