Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex DataGrid: Change value based on another value?
    primarykey
    data
    text
    <p>I have a DataGrid in Flex, with one column a checkbox and another a numeric value. When the checkbox is clicked, the numeric value should change, either to 0 if the checkbox is unselected, or to a pre-defined minimum value if the checkbox is selected. Here is the code I have:</p> <pre><code>&lt;mx:DataGrid x="0" y="45" width="272" height="525" dataProvider="{dp}" variableRowHeight="true" editable="true" id="equipmentDG" verticalAlign="middle"&gt; &lt;mx:columns&gt; &lt;mx:DataGridColumn headerText="" headerStyleName="gridheader" width="20" dataField="included" editorDataField="selected" rendererIsEditor="true"&gt; &lt;mx:itemRenderer&gt; &lt;fx:Component&gt; &lt;mx:CheckBox click="handleClicks(event)"&gt; &lt;fx:Script&gt; &lt;![CDATA[ public function handleClicks(event:MouseEvent):void { data.included = !data.included; if(data.included &amp;&amp; data.antal == 0) data.antal = data.minNo; else if(!data.included) data.antal = 0; } ]]&gt; &lt;/fx:Script&gt; &lt;/mx:CheckBox&gt; &lt;/fx:Component&gt; &lt;/mx:itemRenderer&gt; &lt;/mx:DataGridColumn&gt; &lt;mx:DataGridColumn headerText="Antal" headerStyleName="gridheader" width="40" dataField="antal" editorDataField="value" editable="true"&gt; &lt;mx:itemEditor&gt; &lt;fx:Component&gt; &lt;mx:NumericStepper stepSize="1" width="35" height="20" focusOut="numericstepper1_changeHandler(event)"&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.events.NumericStepperEvent; override public function set data(value:Object):void { super.data = value; if (value &amp;&amp; value.hasOwnProperty("minNo")) minimum = value.minNo; if (value &amp;&amp; value.hasOwnProperty("maxNo")) maximum = value.maxNo; } protected function numericstepper1_changeHandler(event:Event):void { if(data.antal &gt; 0) data.included = true; else data.included = false; } ]]&gt; &lt;/fx:Script&gt; &lt;/mx:NumericStepper&gt; &lt;/fx:Component&gt; &lt;/mx:itemEditor&gt; &lt;/mx:DataGridColumn&gt; &lt;/mx:columns&gt; &lt;/mx:DataGrid&gt; </code></pre> <p>The value updates in the data (I can see it when I close and open the dialog this is in), but it doesn't update instantly in the data grid. How can I make the value visibly change as soon as the checkbox is clicked?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload