Set selected index for DataGrid : DataGrid « Grid « Flex






Set selected index for DataGrid

Set selected index for DataGrid
     

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <mx:Script>
        
            import mx.collections.ArrayCollection;
            import mx.events.CuePointEvent;
            import mx.events.VideoEvent;

            [Bindable]
            private var arrColl:ArrayCollection = new ArrayCollection()

            private function doVideoEvent(evt:VideoEvent):void {
                doAddItem({type:evt.type});
            }

            private function doCuePointEvent(evt:CuePointEvent):void {
                doAddItem({type:evt.type});
            }

            private function doProgressEvent(evt:ProgressEvent):void {
                doAddItem({type:evt.type});
            }

            private function doAddItem(obj:Object):void {
                arrColl.addItem({type:obj.type, state:videoDisplay.state, playheadTime:videoDisplay.playheadTime, totalTime:videoDisplay.totalTime});
                dataGrid.validateNow();
                dataGrid.selectedIndex = arrColl.length;
                dataGrid.scrollToIndex(arrColl.length);
            }
      
    </mx:Script>

    <mx:VideoDisplay id="videoDisplay" source="http://server.com/a.flv" 
            autoPlay="false" 
            autoRewind="false"
            ready="doVideoEvent(event);"
            rewind="doVideoEvent(event);"
            playheadUpdate="doVideoEvent(event);"
            close="doVideoEvent(event);"
            complete="doVideoEvent(event);"
            progress="doProgressEvent(event);" />

    <mx:HBox>
        <mx:Button label="play()" click="videoDisplay.play();" />
        <mx:Button label="pause()" click="videoDisplay.pause();" />
        <mx:Button label="stop()" click="videoDisplay.stop();" />
    </mx:HBox>

    <mx:DataGrid id="dataGrid" dataProvider="{arrColl}" width="320" rowCount="5">
        <mx:columns>
            <mx:DataGridColumn id="typeCol"         dataField="type" headerText="Evt. type" />
            <mx:DataGridColumn id="stateCol"        dataField="state" />
            <mx:DataGridColumn id="playheadTimeCol" dataField="playheadTime" textAlign="right" />
            <mx:DataGridColumn id="totalTimeCol"    dataField="totalTime" textAlign="right" />
        </mx:columns>
    </mx:DataGrid>

</mx:Application>

   
    
    
    
    
  








Related examples in the same category

1.Scroll DataGridScroll DataGrid
2.Variable row heightsVariable row heights
3.Multi-line data grid rowMulti-line data grid row
4.variable scope for DataGridvariable scope for DataGrid
5.Creating inline item renderer and editorCreating inline item renderer and editor
6.Using a DataGridUsing a DataGrid
7.Formatting grid lines with CSSFormatting grid lines with CSS
8.Set editing position for DataGridSet editing position for DataGrid
9.Append new value to DataGrid from Form fieldsAppend new value to DataGrid from Form fields
10.Item click event for DataGridItem click event for DataGrid
11.Editable DataGridEditable DataGrid
12.Variable row height DataGridVariable row height DataGrid
13.DataGrid change eventDataGrid change event
14.Use Panel to layout controls and hold DataGridUse Panel to layout controls and hold DataGrid
15.DataGrids take a dataProvider to populate themDataGrids take a dataProvider to populate them
16.Default setting for DataGridDefault setting for DataGrid
17.Call HTTP server and set result to DataGrid
18.Binding XML to DataGridBinding XML to DataGrid
19.DataGrid Configuration through ActionScriptDataGrid Configuration through ActionScript
20.DataGrid Validate NowDataGrid Validate Now
21.DataGrid Validate Now Selected indexDataGrid Validate Now Selected index
22.DataGrid with static string valuesDataGrid with static string values
23.DataGrid DataDataGrid Data
24.DataGrid EventsDataGrid Events
25.Sort a DataGridSort a DataGrid
26.Inline DataGrid Image ScopeInline DataGrid Image Scope
27.Print DataGrid outPrint DataGrid out
28.Enabling the user to move many items at onceEnabling the user to move many items at once
29.data provider contains fields for an artist, album name, and price.data provider contains fields for an artist, album name, and price.