Thanks, Michael - this initially didn't work, but it made me realize
why some previous attempts of mine also failed: since RemoteObject is
my dataProvider, I have to wait until the (asynchronous) call to this
service completes, before doing any overrides in code after the
service call; my earlier attempts changed the "visible" property
immediately after the code line that invoked the RemoteObject - i.e.,
I had assumed the call was synchronous.

So I set the "result" property of the RemoteObject to "hideName()",
with hideName() declared as follows (same thing your code does):        

        private function hideName():void {
                myDataGrid.columns[0].visible = true; 
                myDataGrid.columns[0].visible = false;
                }

There's still an annoying screen flicker (as the column is very
briefly visible), but it's a workaround.  Glad to also hear that the
next patch will fix this.

Thanks again!  This is a great forum.

-Peter Demling
 Lexington, MA

--- In flexcoders@yahoogroups.com, Michael Imhoff <[EMAIL PROTECTED]> wrote:
>
> Hi Peter,
> 
>  
> 
> I recently posted about a very similar issue that might be of some help.
> Please take a look at
>
http://michael.omnicypher.com/2007/03/issues-with-datagrid-column-visibility
> .html and let me know if that does the trick.
> 
>  
> 
> Hope this helps,
> 
> Michael
> 
>  
> 
>   _____  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of sanjaypmg
> Sent: Friday, March 16, 2007 1:43 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Fascinating problem hiding columns in a
DataGrid
> 
>  
> 
> Hi,
> 
> I have done the same using remote object but didnt face this sort of 
> problem. I am making the columns visible/invisible on the basis of 
> value coming frm the database...
> 
> Thanks
> Sanjay
> 
> --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
ups.com,
> "Peter Demling" <pdemling@> 
> wrote:
> >
> > While a problem for me, I find the following behavior fascinating 
> and
> > inexplicable; so here's a good challenge for any Flexlock Holmes 
> out
> > there (full code is below - 26 lines, fairly simple):
> > 
> > I have a DataGrid that's using a RemoteObject as its dataProvider, 
> and
> > I initialize the 'visible' propery of its first dataGridColumn to
> > "false". On startup, this column (labelled "Name") is hidden - so
> > far, so good.
> > 
> > Next I click my "GetData" button to invoke the RemoteObject's 
> service,
> > and poof! The column becomes visible - even though the debugger
> > verified that its visible property remains false!
> > 
> > So now I click my "HideName" Button, which forcibly sets the 
> visible
> > property of this "Name" column to false. The debugger verifies 
> that
> > its false before I click it, and its false after I click it. 
> Still,
> > the column remains visible.
> > 
> > So just for the heck of it I click my "ShowName" Button, which
> > forcibly sets the visible property of the "Name" column to true. 
> The
> > debugger verifies that the value is changed to true - and as an 
> added
> > bonus, it increases the width of the Name column from 50 to 100! 
> Okay...
> > 
> > Finally, I click the "HideName" Button, and *this* time it works - 
> the
> > Name column is now hidden, having worked only after I forced its
> > visible prpoerty to true immediately beforehand.
> > 
> > I can replicate this ad nauseum (calling the RemoteObject service
> > makes the hidden column visible without setting visible to true;
> > forcing the visible value to false works only after forcing it to
> > true), but it only happens when the dataProvider is remoteObject, 
> and
> > the forcing of the visible value only shows the column when done 
> via
> > Buttons (it does not work directly in code right after calling the
> > RemoteObject service).
> > 
> > Full code is below. I tracked every single Name column variable
> > through the debugger, and nothing changes, except for visible and
> > width as noted above. I did track down the moment that 
> the "ShowName"
> > button expands the column width (in Button.as, line 2050, function
> > focusOutHandler), but I don't know enough about Flex yet to know 
> why
> > that would enable column hiding; or why the call to RemoteObject is
> > revealing my invisible column in the first place, for that matter.
> > 
> > Started out just wanting to hide some DataGrid columns, but went
> > pretty far down the rabbit hole. Thanks for any input!
> > 
> > -Peter Demling
> > Lexington, MA
> > 
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.
> <http://www.adobe.com/2006/mxml> com/2006/mxml"
> > layout="absolute">
> > 
> > <mx:RemoteObject id="srv" destination="employees"/>
> > 
> > <mx:DataGrid id="myDataGrid"
> > dataProvider="{srv.getEmployees.lastResult}">
> > <mx:columns>
> > <mx:DataGridColumn visible="false"
> > headerText="Name" dataField="name" />
> > <mx:DataGridColumn
> > headerText="Group" dataField="group"/>
> > </mx:columns>
> > </mx:DataGrid>
> > 
> > <mx:Button label="Get Data" click="srv.getEmployees();"
> > x="10" y="170"/> 
> > <mx:Button label="Hide name column" 
> > click="myDataGrid.columns[0].visible=false;" 
> > y="230" x="10"/> 
> > <mx:Button label="Show name column"
> > click="myDataGrid.columns[0].visible=true;"
> > y="200" x="10"/>
> > 
> > </mx:Application>
> >
>


Reply via email to