Hello,
I think we can use something like changewatcher and than pass
arraycollection which is bind.So whenever checkbox state is changed it will
be updated.

abhilash

On Sat, May 7, 2011 at 5:51 PM, Sudhakar <[email protected]> wrote:

> Hi all,
>
> I am creating a datagrid on th fly.
> Datagrid is working fine.
> i creating a chackbox item renderer and the check box is displaying in
> the datagrid.
>
> My Problem:
> **********************
>   When change the state of checkbox i want to update the value in
> bindable arraycollection. but it is not updating.
>
>  Please give me solution for how to update a value in bindable
> dataArray:ArrayCollection when change the state of CheckBox from
> CheckBox Itemrenderer.
>
>
> My Code:
> *************************
>
> [Bindable]
> private var dataArray:ArrayCollection;
>
> // Retrieving data using JSON
> private function
> createDataGridUserAssignmentQuestions( event:ResultEvent ):void {
>
>
>        var rawArray:Array;
>        var rawData:String = String(event.result);
>        rawArray = JSON.decode(rawData) as Array;
>        dataArray = new ArrayCollection(rawArray);
>
>        creationCompleteHandler( event );
> }
>
> // Creating DataGrid.
> private function creationCompleteHandler( evt:ResultEvent ) : void
> {
>
>        var columns:Array = new Array();
>
>        columns.push(getColumn("Completed", "Completed"));
>        columns.push(getColumn("StudentName", "Student Name"));
>
>        var iQuestionIndex:int = 1;
>        for(var i:int = 0; i < iTotalQuestions; i++)
>        {
>
>                var columnTitle:String;
>
>                columnTitle = "Q" + (iQuestionIndex);
>                iQuestionIndex++;
>
>                columns.push(getColumn("QuestionResponsesAnswerChosen" + i,
> columnTitle ));
>        }
>
>        var grid:DataGrid = new DataGrid();
>
>        grid.columns = columns;
>        grid.percentWidth = 100;
>        //grid.height = 215;
>        grid.height = 215;
>        grid.lockedColumnCount = 2;
>        grid.editable = true;
>        //grid.rowCount = dataArray.length;
>        grid.horizontalScrollPolicy = ScrollPolicy.AUTO;
>        grid.setStyle('horizontalScrollBarStyleName','customScroll');
>        grid.setStyle('verticalScrollBarStyleName','customScroll');
>
>        grid.dataProvider = dataArray; //rows;
>
>        grid.addEventListener(ListEvent.ITEM_CLICK, onColumnSelect );
>        grid.addEventListener(FlexEvent.CREATION_COMPLETE, getFirstQuestion
> )
>
>        QuestionGridStage.addElement(grid);
> }
>
> // Creating Colomuns
> private function getColumn(dataField:String,
> headerText:String):DataGridColumn
> {
>        var column:DataGridColumn = new DataGridColumn(dataField);
>                column.headerText = headerText;
>                column.draggable = false;
>
>                if(headerText == "Student Name"){
>                        column.editable = false;
>                        column.width = 150;
>                } else if(headerText == "Completed"){
>                        column.setStyle("textAlign","center");
>                        column.editable = false;
>                        column.width = 80;
>                        column.itemRenderer = new
> ClassFactory(checkBoxAssignment); // HERE
> I NEED HELP
>                }else {
>                        column.setStyle("textAlign","center");
>                        column.resizable = false;
>                        column.width = 50;
>                        column.itemRenderer = new
> ClassFactory(GridColumnInputTextBoxRenderer);
>                        column.rendererIsEditor = true;
>                }
>
>        return column;
> }
>
> // CheckBox Renderer
> <?xml version="1.0" encoding="utf-8"?>
> <mx:CheckBox xmlns:mx="http://www.adobe.com/2006/mxml";
> horizontalCenter="0" verticalCenter="0" >
>        <mx:Script>
>                <![CDATA[
>                        import mx.controls.Alert;
>                        import mx.controls.dataGridClasses.DataGridListData;
>
>                        [Bindable] private var formattedValue:Boolean;
>
>                        override public function set data(value:Object):void
>                        {
>                                super.data = value;
>
>                                formattedValue = data[(listData as
> DataGridListData).dataField];
>
>                                this.selected = formattedValue;
>                        }
>
>                        protected function changeValue(event:Event):void
>                        {
>
>                                formattedValue = this.selected;
>
>                        }
>
>                ]]>
>        </mx:Script>
>
> </mx:CheckBox>
>
>
>
> --
> 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.
>
>

-- 
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