dataProvider and DataGrid : dataProvider « Data Model « Flex






dataProvider and DataGrid

          
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        
            import mx.controls.TextInput;
            import mx.events.DataGridEvent;
            import mx.collections.ArrayCollection;
            
            [Bindable]
            private var productsAC:ArrayCollection = new ArrayCollection
            (
                [
                    {Product: "iPod", Price: 249},
                    {Product: "iMac", Price: 1299},
                    {Product: "MacBook Pro", Price: 1999}
                ]
            );
            
            private function getCellInfo(event:DataGridEvent):void
            {
                var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
                var newVal:String = myEditor.text;
                var oldVal:String = event.currentTarget.editedItemRenderer.data[event.dataField];
                cellInfo.text += "Row, column: " + event.rowIndex + ", " + event.columnIndex + "\n";
                cellInfo.text += "New value: " + newVal + "\n";
                cellInfo.text += "Old value: " + oldVal;
            }
            
      
    </mx:Script>
    
    <mx:TextArea id="cellInfo" width="300" height="150" />
    
    <mx:DataGrid dataProvider="{productsAC}" editable="true" itemEditEnd="getCellInfo(event)">
        <mx:columns>
            <mx:DataGridColumn dataField="Product" />
            <mx:DataGridColumn dataField="Price" />
        </mx:columns>
    </mx:DataGrid>
    
</mx:Application>

   
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Script section and dataProvider sectionScript section and dataProvider section
2.Set data for TabBar using and Set data for TabBar using <mx:dataProvider> and <mx:TabBar>
3.Create a Legend control is to bind a chart to it by using the dataProvider propertyCreate a Legend control is to bind a chart to it by using the dataProvider property
4.populating dataProvider by using the populating dataProvider by using the <mx:dataProvider/>
5.uses event handlers to add and remove container children by calling addItem()/removeItemAt() on dataProvider propertyuses event handlers to add and remove container children by calling addItem()/removeItemAt() on dataProvider property
6.Creating a TabBar control, use and tags to specify the text for each tabCreating a TabBar control, use <mx:dataProvider> and <fx:String> tags to specify the text for each tab
7.MultipleDataProviders.mxmlMultipleDataProviders.mxml
8.Change Service DataProviderChange Service DataProvider
9.A custom function to convert new data items to the format required by the data providerA custom function to convert new data items to the format required by the data provider