Try this. You can buil on this depends on how you want to save the
data (XML, or table structure)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
                                layout="vertical"
                                verticalAlign="middle"
                                backgroundColor="white">

        <mx:Script>
        <![CDATA[
                import mx.events.IndexChangedEvent;
                import mx.controls.dataGridClasses.DataGridColumn;
                import mx.controls.Alert;
                import mx.collections.ArrayCollection;

                [Bindable]private var arrayOfString:Array;

                [Bindable]
                public var dgArray:ArrayCollection = new ArrayCollection([
                        {Price:'Lots', Store:'yahoo', Artist:'Jack'},
                        {Price:'None', Store:'amazon', Artist:'Jill'}
                ]);

                private function init():void {
                        myGrid.dataProvider = dgArray;
                        myGrid.addEventListener(IndexChangedEvent.HEADER_SHIFT,
onColumnShift);

                        var array:Array = myGrid.columns;
                        var newOrderArray:Array = new Array(3);
                        for (var i:int=0; i<array.length; i ++) {
                                var dgc:DataGridColumn = array[i] as 
DataGridColumn;
                                if (dgc==null)
                                        continue;
                                if (dgc.dataField=="Price")
                                        newOrderArray[2] = dgc;
                                else if (dgc.dataField=="Store") {
                                        newOrderArray[0] = dgc;
                                }
                                else if (dgc.dataField=="Artist")
                                        newOrderArray[1] = dgc;
                        }
                        myGrid.columns = newOrderArray;
                        myGrid.validateNow();
                }

                private function onColumnShift(event:IndexChangedEvent):void {
                        var columns:Array = myGrid.columns;
                        var text:String = new String();
                        for (var i:int=0; i<columns.length; i ++) {
                                var dgc:DataGridColumn = columns[i] as 
DataGridColumn;
                                text += (DataGridColumn(dgc).dataField + " - ");
                        }
                        Alert.show(text);
                }

        ]]>
        </mx:Script>

        <mx:DataGrid id="myGrid" initialize="init();">
        </mx:DataGrid>

</mx:Application>


On Mar 9, 2:49 am, swathi <[email protected]> wrote:
> Hello All,
>
> I am working on DataGrid . Here i need to save the columns order ;
> that is if the default order of columns A B C is A B C and if i change
> the columns to  B C A , my data base should store this when i ask for
> saving and display the same when i reopen the grid.
>
> suggestions please ...
>
> Thanks ,
> Swathi.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to