Hi all,
I am trying to implement the following:
When the user click on a given cell on ADG, the style of the row OR
column (depending on a selection criteria, e.g.) should take the style
giving by style options (comboBoxes and colorPicker components). This
style should be fixed until the user changes it by the use of the
style options.

For the time being, I have used the great tutorial at:
http://flexpearls.blogspot.com/2008/02/row-background-color-in.html

/*************************************************************/
private function aDGStyleFunction(data:Object,
col:AdvancedDataGridColumn):Object {
        var styleObject : Object;
        if(selectedRowIndex > -1 && selectedRowIndex <
myADG.dataProvider.length) {
                var myIndex:int = myADG.dataProvider.getItemIndex( data );
                if (myIndex == selectedRowIndex) {
                        styleObject = {rowColor : colorPicker.selectedColor,
fontFamily : family.selectedLabel,
                                fontSize : Number(size.selectedLabel)};
                        return styleObject;
                }
        }
        return {};
}

private function triggerADGUpdate():void {
        myADG.itemRenderer = new ClassFactory(AdvancedDataGridRendererEx);
}

private function changeFontFamily(event : Event) : void {
        myADG.itemRenderer = new ClassFactory(AdvancedDataGridRendererEx);
}

private function changeFontSize(event : Event) : void {
        myADG.itemRenderer = new ClassFactory(AdvancedDataGridRendererEx);
}

 private function changeBackgroundColor(event : Event) : void {
        myADG.itemRenderer = new ClassFactory(AdvancedDataGridRendererEx);
 }

 private function initADG() : void {
        myADG.addEventListener(MouseEvent.CLICK, myMouseClickHandler);
 }

 private function myMouseClickHandler(event : MouseEvent) : void {
        selectedRowIndex = myADG.selectedCells[0].rowIndex;
}

<mx:Panel title="AdvancedDataGrid Control Example"
        height="75%" width="75%" layout="vertical"
        paddingTop="10" paddingBottom="10" paddingLeft="10"
paddingRight="10">

        <mx:HBox>
                <mx:Label text="Font Family:"/>
                <mx:ComboBox id="family" labelField="Font Family:"
selectedIndex="1" dataProvider="{fontFamilies}"
change="triggerADGUpdate()"/>

                <mx:Label text="Font Size:"/>
                <mx:ComboBox id="size" labelField="Font Size:" selectedIndex="2"
dataProvider="{fontSizes}" change="triggerADGUpdate()"/>

                <mx:Label text="Font Color:"/>
                <mx:ColorPicker id="colorPicker" selectedColor="0xFFFFFF"
change="triggerADGUpdate()"/>
        </mx:HBox>

        <mx:AdvancedDataGrid
                id="myADG"
                dataProvider="{dpFlat}"
                selectionMode="singleCell"
                styleFunction="aDGStyleFunction"
                creationComplete="initADG();"
                itemRenderer="asclasses.AdvancedDataGridRendererEx"

        />
    </mx:Panel>

/*************************************************************/

For the row style, It works strangely:
- I click on a cell, the style of the corresponding row is not changed
until I move the mouse out of the selected cell?
- When I do so, the row style is changed (according to the style
options), if then I click on another cell of another row, and the row
style is changed, and then I moved over the first changed row its new
style is disappeadred.
this is clear since if (myIndex == selectedRowIndex) in the
styleFunction will not be correct for previous rows.

I want to save the style, Does anybody has any idea how to preserve
the styles! I have a terrible idea of saving every selected row and
its style options!! I think it must be some other elegant solution
over there!

Another problem is that: Should I applya a separate itemrenderer for
the columns or there is a way to combine column renderers and the
above used renderer

Please Help!
Thanks in advanced!
mman



--

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