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], "Peter Demling" <[EMAIL PROTECTED]> 
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.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