0

我有一个带有 ItemRenderer 和 ItemEditor 的数据网格。单击时,由于我的数据网格是可编辑的,我可以修改编辑单元格的值。但是,当我使用 Tab 键验证这些更改时,例如,itemrender 值与开始时相同,没有出现任何更改。

你能告诉我如何解决这个问题吗?

<mx:DataGridColumn dataField="scRub2" headerText="{sNomCol2}" 
editable="true" width="{iNomCol2}"id="dgc1" wordWrap="true"
                                                                itemRenderer="itemRenderer.MultilineHTMLRenderer"
itemEditor="itemRenderer.irHtmlText"
editorDataField="htmlModif"

// 项目编辑器

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[

        public var htmlModif:String;
        protected function lblData_changeHandler(event:Event):void
        {
            htmlModif = lblData.htmlText;
        }
    ]]>
</fx:Script>


<mx:TextArea id="lblData" top="0" left="0" right="0" bottom="0"     
             htmlText="{dataGridListData.label}"  preinitialize="initTA()"
             change="lblData_changeHandler(event)">
    <fx:Script>
        <![CDATA[

            import flash.events.Event;

            import mx.controls.dataGridClasses.DataGridListData;

            import mx.controls.dataGridClasses.DataGridListData;
            import mx.controls.listClasses.BaseListData;
            [Bindable("dataChange")] private var _listData : BaseListData;

            override public function get listData():BaseListData
            {
                return _listData;            
            }                   
            override public function set listData( value : BaseListData ) : void
            {
                _listData = value;
            }

            private function onChange(event:Event):void
            {
                this.data[ (listData as DataGridListData).dataField ] = lblData.htmlText;
            }
            public function initTA():void {         
                addEventListener("dataChange", handleDataChanged);
            }   

            public function handleDataChanged(event:Event):void {       
                // Cast listData to DataGridListData. 
                var myListData:DataGridListData = 
                    DataGridListData(listData);
                // Access information about the data passed 
                // to the cell renderer.
                trace("row index: " + String(myListData.rowIndex) + 
                    " column index: " + String(myListData.columnIndex));

            }
        ]]>
    </fx:Script>
</mx:TextArea>

谢谢

4

1 回答 1

0

我没有运行您的代码,但认为将字段htmlModif更改为get函数将解决您的问题

public var htmlModif:String;
        protected function lblData_changeHandler(event:Event):void
        {
            htmlModif = lblData.htmlText;
        }

    public function get htmlModif():String
    {
        return lblData.htmlText;
    }

希望有帮助

于 2012-05-29T17:22:30.177 回答