달력

5

« 2025/5 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'felx4.5'에 해당되는 글 1

  1. 2011.10.12 [Flex] spark datagrid itemeditor
2011. 10. 12. 11:57

[Flex] spark datagrid itemeditor 공부/flex2011. 10. 12. 11:57


mx dataGrid 는 itemEditor를 사용해서 값을 바꾸면 바로 적용되는데...

spark dataGrid는 값이 Commit 되지않는다..

mx dataGrid에서 column에 editorDataField속성에 값을 지정해주면 바로 커밋되는데.....

왤까....????? spark column에는속성도없고... 뭘써야되는지....-_-

오늘의 숙제다.


--------------------------------------------------------------------------------------------
Adobe Help 참조
<?xml version="1.0" encoding="utf-8"?>
<!-- dpcontrols\sparkdpcontrols\SparkDGItemEditor.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" 
    width="450">
    <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>
    
    <s:DataGrid id="myDG" width="100%" 
        dataProvider="{myDP}" 
        variableRowHeight="true" 
        editable="true" >
        <s:columns>
            <s:ArrayList>
                <s:GridColumn dataField="label1" headerText="Order #"/>
                <s:GridColumn dataField="quant" 
                    headerText="Qty"
                    itemEditor="myComponents.DGNumStepperEditor"/>
            </s:ArrayList> 
        </s:columns >
    </s:DataGrid> 
</s:Application>

<?xml version="1.0" encoding="utf-8"?>
<!-- dpcontrols\sparkdpcontrols\myComponents\DGNumStepperEditor.mxml -->
<s:GridItemEditor 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[
            
            // Override the setter to initialize the NumericStepper control
            // with the cell data.
            override public function set value(newValue:Object):void {
                ns.value = newValue as Number;
            }

            // Override the getter to return the current value of 
            // the NumericStepper control.
            // The save() method updates the data provider element for the
            // row of the grid with this value. 
            override public function get value():Object {
                return ns.value;
            }
            
            // Override setFocus() to shift focus to the NumericStepper.
            override public function setFocus():void {
                ns.setFocus();
            }
        ]]>
    </fx:Script>

    <s:NumericStepper id="ns" width="100%"
        fontWeight="bold"/>
</s:GridItemEditor>
flex 4.5 부터는 set value 와 get value로 자동 commit이 되네...
:
Posted by 알 수 없는 사용자