Edit Event Prevents Edit : Event « Event « Flex






Edit Event Prevents Edit

Edit Event Prevents Edit
           
<!--
Code from Flex 4 Documentation "Using Adobe Flex 4".

This user guide is licensed for use under the terms of the Creative Commons Attribution 
Non-Commercial 3.0 License. 

This License allows users to copy, distribute, and transmit the user guide for noncommercial 
purposes only so long as 
  (1) proper attribution to Adobe is given as the owner of the user guide; and 
  (2) any reuse or distribution of the user guide contains a notice that use of the user guide is governed by these terms. 
The best way to provide notice is to include the following link. 
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/

-->



<!-- itemRenderers\events\EndEditEventPreventEdit.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> 
         
        import mx.events.DataGridEvent; 
        import mx.collections.ArrayCollection; 
        [Bindable] 
        private var initDG:ArrayCollection = new ArrayCollection([ 
            {Artist:'Pavement', Album:'Slanted and Enchanted',Price:11.99}, 
            {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99} 
        ]); 
        // Define event listener for the cellEdit event 
        // to prohibit editing of the Album column. 
        private function disableEditing(event:DataGridEvent):void { 
            if(event.columnIndex==1){ 
                event.preventDefault(); 
            } 
        } 
      
    </fx:Script>
    <mx:DataGrid id="myGrid" dataProvider="{initDG}" editable="true"
        itemEditBeginning="disableEditing(event);">
        <mx:columns>
            <mx:DataGridColumn dataField="Artist" />
            <mx:DataGridColumn dataField="Album" />
            <mx:DataGridColumn dataField="Price" />
        </mx:columns>
    </mx:DataGrid>
</s:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Stop event propagationStop event propagation
2.Hold down the Shift key while pressing the mouse buttonHold down the Shift key while pressing the mouse button
3.Set the value of the errorString property to create an error tipSet the value of the errorString property to create an error tip
4.Nested inner functionNested inner function
5.Submit button callSubmit button call
6.Add a new button when the user presses an existing buttonAdd a new button when the user presses an existing button
7.Manually dispatch an event in an MXML tagManually dispatch an event in an MXML tag
8.UI Control initialization eventUI Control initialization event
9.Add ActionScript code in the component's definition for initialize eventAdd ActionScript code in the component's definition for initialize event
10.Use dispatchEvent() method to dispatch any eventUse dispatchEvent() method to dispatch any event
11.Dispatch an event in an MXML tagDispatch an event in an MXML tag
12.Create new event from ActionScriptCreate new event from ActionScript
13.Single event property accessSingle event property access
14.Add loading complete event for URLLoader
15.Create Complete event and initialize eventCreate Complete event and initialize event
16.Cast event sender to UI controlCast event sender to UI control
17.Module loading eventModule loading event
18.Using error event when loading ModuleUsing error event when loading Module
19.Handling Events InlineHandling Events Inline
20.Use Event BubblingUse Event Bubbling
21.Bind getter function to phoneNumberChanged eventBind getter function to phoneNumberChanged event
22.NonCommittingChangeEvent DemoNonCommittingChangeEvent Demo
23.NonCommittingChange Event SampleNonCommittingChange Event Sample
24.StartUp event OrderStartUp event Order
25.Event With FunctionEvent With Function
26.Event BubblingEvent Bubbling
27.Set HTMLText With Initialize eventSet HTMLText With Initialize event
28.Get Scrolled position from ScrollEventGet Scrolled position from ScrollEvent
29.Change EventChange Event
30.Using change event to recognize that a new item was entered into the prompt, and adds it to the data providerUsing change event to recognize that a new item was entered into the prompt, and adds it to the data provider