开发者

Flex DataGrid itemEditEnd event + preventDefault function

im working with flex's datagrid.

I have a DataGridColumn defined as the following, where labelFunction would allow me to display a custom text.

I am also using a itemEditEnd handler on the grid to manipulate the entered data for this column. The purpose is to take the user input and split it then store the result in different properties other than "fixedValue".

my problem with this approach is that i can't find a way to prevent assignment to the fixedValue property (which doesn't exist). And using event.preventDefault() in the itemEditEnd handler would stop other events from happening like changing the row from edit mode to the view mode.

my question is that if there is other way to achieve the same thing, or a way to just prevent the assignment of the "dataField" data.

thanks

i am using the dataField to identify the column i am edit开发者_运维百科ing. Leaving it null might not be an option.

<mx:DataGridColumn id="columnFixedCurrency" labelFunction="fixedCurrecy_labelFunc" dataField="fixedValue" headerText="Price"/>


Dont use itemEditEnd.It wud be better to use CollectionEvent on the dataprovider for your grid.If you want to use itemEditEnd have a separate column for storing the changed value and the value entered by user can be kept intact in the columnFixedCurrency.I created an example .the value entered by user in one column is distributed in half in two columns,using collectionChange on the ArrayCollection.HTH

         <?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
    <![CDATA[
        import mx.events.CollectionEvent;
        import mx.controls.Alert;
        import mx.events.DataGridEvent;
        import mx.events.ListEvent;
        public function splitValues(event:CollectionEvent):void{
           if(dg !=null )
           {
            dg.selectedItem.splitValue1 = dg.selectedItem.fixedValue /2;
            dg.selectedItem.fixedValue = dg.selectedItem.fixedValue /2;

           }

        }
    ]]>
</mx:Script>




<mx:DataGrid id="dg"  editable="true" >
    <mx:columns>
        <mx:DataGridColumn dataField="splitValue1" headerText="Split Price1" id="columnSplitCurrency1" editable="false"/>
        <mx:DataGridColumn id="columnFixedCurrency"  dataField="fixedValue" headerText="Price"/> 

    </mx:columns>
     <mx:dataProvider>
       <mx:ArrayCollection id="myAC" collectionChange="splitValues(event)">
        <mx:Object splitValue1="0" fixedValue="25"  splitValue2="0"/>
        <mx:Object splitValue1="0" fixedValue="15" splitValue2="0"/>
        <mx:Object splitValue1="0" fixedValue="35" splitValue2="0" />
        <mx:Object splitValue1="0" fixedValue="45" splitValue2="0"/>
        <mx:Object splitValue1="0" fixedValue="65" splitValue2="0"/>
       </mx:ArrayCollection>
     </mx:dataProvider>
</mx:DataGrid></mx:Application>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜