0

我有一个带有 textArea 的项目渲染器。

    <?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                          xmlns:s="library://ns.adobe.com/flex/spark" 
                          xmlns:mx="library://ns.adobe.com/flex/mx" 
                          focusEnabled="true">

    <fx:Script>
        <![CDATA[
            import mx.controls.DataGrid;
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.controls.listClasses.BaseListData;
            import mx.core.UITextField;
            public var htmlModif:String;

            /*  protected function lblData_changeHandler(event:Event):void
             {
                 htmlModif=lblData.htmlText;
                 dataGridListData.label = htmlModif;

             } */

            override public function validateProperties():void
            {
                super.validateProperties();
                if (listData)
                {
                    var dg:DataGrid = DataGrid(listData.owner);

                    var column:DataGridColumn = dg.columns[listData.columnIndex];

                    var htmlText:UITextField = lblData.htmlText as UITextField;

                }


            }
        ]]>
    </fx:Script>

    <mx:TextArea id="lblData" top="0" left="0" right="0" bottom="0" 
                 htmlText="{dataGridListData.label}" 
                 wordWrap="true"
                 editable="true"
                 creationComplete="htmlModif=lblData.htmlText"
                 change="htmlModif=lblData.htmlText"/>
</s:MXDataGridItemRenderer>

更改后,我将 htmlModif 放在 arraycollection 上以保存新值。

在某些情况下,我喜欢更改部分文本的颜色或样式。如果更改与样式有关(粗体,斜体......),它适用于所有文本

DP_LISTEREDVCLI[ligneIndexEdit].scRub2="<b>"+DP_LISTEREDVCLI[ligneIndexEdit].scRub2+"</b>

但是,如果更改与颜色有关,我将不起作用:

DP_LISTEREDVCLI[ligneIndexEdit].scRub2=""+DP_LISTEREDVCLI[ligneIndexEdit].scRub2+"";

我认为这种干扰是因为在这种情况下,新值是这样的:

<FONT COLOR='#FFAE10'> <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#0C1E37" LETTERSPACING="0" KERNING="0">mais pas de disparition</FONT></P></TEXTFORMAT></FONT>

那么,你能帮我解决这个问题吗?

感谢您的帮助

4

1 回答 1

0

试试这个,我附上了输出的屏幕截图, 在此处输入图像描述

<?xml version="1.0" encoding="utf-8"?>
<s:Application
    xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:mx="library://ns.adobe.com/flex/mx">


    <fx:Script>
        <![CDATA[
            import mx.collections.*;
            private var DGArray:Array = [
                {Artist:'Pavement 1 ', label:'Slanted and Enchanted', Price:11.99},
                {Artist:'Pavement 2 ', label:'without color <FONT COLOR="#FF00FF"> <TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="12" COLOR="#FF00FF" LETTERSPACING="0" KERNING="0">Slanted and Enchanted</FONT></P></TEXTFORMAT></FONT>', Price:15.99}];

        ]]>
    </fx:Script>

    <mx:DataGrid id="myGrid" width="100%" height="100%" 
                 dataProvider="{DGArray}" itemRenderer="IR" >

    </mx:DataGrid>
</s:Application>

Itemrenderer 代码,

<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                          xmlns:s="library://ns.adobe.com/flex/spark" 
                          xmlns:mx="library://ns.adobe.com/flex/mx" 
                          focusEnabled="true">

    <fx:Script>
        <![CDATA[
            import mx.controls.DataGrid;
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.controls.listClasses.BaseListData;
            import mx.core.UITextField;
            public var htmlModif:String;

            /*  protected function lblData_changeHandler(event:Event):void
            {
            htmlModif=lblData.htmlText;
            dataGridListData.label = htmlModif;

            } */

            override public function validateProperties():void
            {
                super.validateProperties();
                if (listData)
                {
                    var dg:DataGrid = DataGrid(listData.owner);

                    var column:DataGridColumn = dg.columns[listData.columnIndex];

                    var htmlText:UITextField = lblData.htmlText as UITextField;

                }


            }
        ]]>
    </fx:Script>

    <mx:TextArea id="lblData" top="0" left="0" right="0" bottom="0" 
                 htmlText="{dataGridListData.label}" 
                 wordWrap="true"
                 editable="true"
                 creationComplete="htmlModif=lblData.htmlText"
                 change="htmlModif=lblData.htmlText"/>
</s:MXDataGridItemRenderer>
于 2012-11-15T11:57:00.453 回答