Flex 学习之路之二十二 DataGrid的使用
程序员文章站
2022-07-07 23:18:32
...
<?xml version="1.0"?>
<!-- itemRenderers\sparkmx\myComponents\NSEditor.mxml -->
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
public var myRetVal:int = 0;
]]>
</fx:Script>
<!-- Use the valueCommit event when the user selects the
cell but does not change the value. -->
<s:NumericStepper id="myNS"
value="{data.quant}"
stepSize="1"
maximum="50"
change="myRetVal=myNS.value;"
valueCommit="myRetVal=myNS.value;"/>
</s:MXDataGridItemRenderer>
<?xml version="1.0"?>
<!-- itemRenderers\sparkmx\SparkMainNSEditor.mxml -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var myDP:ArrayCollection = new ArrayCollection([
{label1:"Order #2314", quant:3, Sent:true},
{label1:"Order #2315", quant:3, Sent:false}
]);
]]>
</fx:Script>
<mx:DataGrid id="myDG" dataProvider="{myDP}"
variableRowHeight="true"
editable="true" >
<mx:columns>
<mx:DataGridColumn dataField="label1"
headerText="Order #"/>
<mx:DataGridColumn dataField="quant"
itemEditor="myComponents.NSEditor"
editorDataField="myRetVal"/>
</mx:columns >
</mx:DataGrid>
</s:Application>