I'm sorry. I wasn't clear. I want the button to enable a component (or
disable it in the case of the reset button). The component is in the
same MXML file.
What seems to work seems pretty involved. I had to bind a variable in
the component and bind one in the main MXML to pass the state (enabled)
in.
The next problem I have is probably simpler, but following two matching
google solutions that failed to work means there is probably a depth to
this problem beyond my ignorance.
I just want a check box or radio button to be included in a grid. Both
solutions that I tried looked like this:
<cust:MyAdvancedDataGrid
id="dgData"
width="100%" height="85%"
textAlign="center"
fontWeight="normal"
dataProvider="{myData}"
selectionMode="singleCell"
accessibilityName="Case Composition, DataGrid,
use arrow keys to navigate between cells">
<cust:columns>
<mx:AdvancedDataGridColumn
headerText="Select"
rendererIsEditor="true"
width="100">
<mx:itemRenderer>
<fx:Component>
<s:CheckBox
selected="false"/>
</fx:Component>
</mx:itemRenderer>
</mx:AdvancedDataGridColumn>
It seems straight forward. Add an itemRenderer as the content of a
cell. To enable the control, add a "FX" container. It doesn't cause
any syntax error, but when you run it you get this:
TypeError: Error #1034: Type Coercion failed: cannot convert
gov.il.dhs.wvs.view.components::UserAA_GridInnerClass0@7cb6cf1 to
mx.controls.listClasses.IListItemRenderer.
at
mx.controls.advancedDataGridClasses::AdvancedDataGridBase/http://www.ado
be.com/2006/flex/mx/internal::columnItemRenderer()[E:\dev\4.x\frameworks
\projects\datavisualization\src\mx\controls\advancedDataGridClasses\Adva
ncedDataGridBase.as:1634]
at
mx.controls::AdvancedDataGridBaseEx/http://www.adobe.com/2006/flex/mx/in
ternal::getMeasuringRenderer()[E:\dev\4.x\frameworks\projects\datavisual
ization\src\mx\controls\AdvancedDataGridBaseEx.as:2812]
at
mx.controls::AdvancedDataGrid/http://www.adobe.com/2006/flex/mx/internal
::getMeasuringRenderer()[E:\dev\4.x\frameworks\projects\datavisualizatio
n\src\mx\controls\AdvancedDataGrid.as:4152]
at
mx.controls::AdvancedDataGridBaseEx/measureItems()[E:\dev\4.x\frameworks
\projects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.as:62
25]
at
mx.controls::AdvancedDataGridBaseEx/commitProperties()[E:\dev\4.x\framew
orks\projects\datavisualization\src\mx\controls\AdvancedDataGridBaseEx.a
s:2274]
at
mx.controls::AdvancedDataGrid/commitProperties()[E:\dev\4.x\frameworks\p
rojects\datavisualization\src\mx\controls\AdvancedDataGrid.as:2846]
at
mx.core::UIComponent/validateProperties()[E:\dev\4.x\frameworks\projects
\framework\src\mx\core\UIComponent.as:7933]
at
mx.managers::LayoutManager/validateProperties()[E:\dev\4.x\frameworks\pr
ojects\framework\src\mx\managers\LayoutManager.as:572]
at
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks
\projects\framework\src\mx\managers\LayoutManager.as:730]
at
mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\fr
ameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
From: [email protected] [mailto:[email protected]] On
Behalf Of Alex Harui
Sent: Friday, June 08, 2012 3:41 PM
To: [email protected]
Subject: Re: [flexcoders] Activate Component (enable)
Assuming the button and ting you want to enable are in the same MXML
file a typical set up looks like
<mx:Button label="enable text search" click="criteria.enabled = true" />
<mx:TextInput id="criteria" enabled=false" />
Even more common is the use of checkboxes for enabling
<mx:CheckBox label="enable text search" id="enableTextSearch" />
<mx:TextInput enabled="{enableTextSearch.selected}" />
In which case you can just use binding.
On 6/8/12 12:19 PM, "Davidson, Jerry" <[email protected]>
wrote:
I couldn't see how to get to the property from the button.
From: [email protected]
[mailto:[email protected]] On Behalf Of Alex Harui
Sent: Friday, June 08, 2012 11:56 AM
To: [email protected]
Subject: Re: [flexcoders] Activate Component (enable)
Why wouldn't you set enabled=true on the button click?
On 6/8/12 6:56 AM, "Davidson, Jerry! "
<[email protected]> wrote:
I have a form that includes a component. The form includes
selection criteria and a search button. When the user clicks the search
button, I want to enable the component and populate a grid of the
results of the search. Taking baby steps, the first thing I want to do
is the enabling.
Search
Results
&nbs! p; ! &n bsp; Select office:
Select Name Case Office
Select case:
&nbs! p; [ ] &n! bsp;&nbs p; x ! x
x
Select from date:
[ ] y y y
&! nbsp; Select to date: &nb! sp;
! ; & nbsp; [ ] z z
z
Search Btn
&n! bsp; Details
! ;
Start End Stuff More Stuff
&! nbsp;
&nb! sp; 1 &nb! sp; ; 1 1 1
&! nbsp;
&nb! sp; ; 2 2
2 &nb! sp; 2
The results and details sections (in same component) are
disabled until a user selects stuff. Step one is to enable the
component when the search button is clicked and all the edit checks are
passed.
I was thinking of passing a boolean in the component bound to a
variabl! e that is defaulted to false and set to true in the search
button code, but that didn't work. I couldn't find a property of the
component that could be set in the search button click event.
TIA,
Jerry
--
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui