Apache flex Labelfunction干扰组合框项编辑器

Apache flex Labelfunction干扰组合框项编辑器,apache-flex,actionscript-3,flex4,Apache Flex,Actionscript 3,Flex4,我的问题是,当用户单击具有组合框编辑器的datagrid单元格,然后立即单击该单元格,该单元格中的文本值就会消失 我在datagrid上有一个itemEditEnd处理程序,它显示了我用作editorDataField的属性值。但该网格列上的labelFunction(在itemEditEnd处理程序之后调用)将其视为零 为什么labelFunction和item editor不能很好地配合使用 以下是DataGrid列: <mx:DataGridColumn

我的问题是,当用户单击具有组合框编辑器的datagrid单元格,然后立即单击该单元格,该单元格中的文本值就会消失

我在datagrid上有一个itemEditEnd处理程序,它显示了我用作editorDataField的属性值。但该网格列上的labelFunction(在itemEditEnd处理程序之后调用)将其视为零

为什么labelFunction和item editor不能很好地配合使用

以下是DataGrid列:

<mx:DataGridColumn  
                                headerText="Field Name" 
                                dataField="attribId"
                                editorDataField="attributeId"
                                labelFunction="getFieldName">
下面是在Datagrid的itemEditEndHandler中执行的代码:

变量行计数:int=fieldsGridEmpty.selectedIndex; var attribCombo:ComboBox=ComboBox(fieldsGridEmpty.itemEditorInstance)

现在,项编辑处理程序显示了“attri同上”的有效值:

newFieldsDp[ rowCount ].attribId = attribCombo.selectedItem.attribId;

但是,标签函数在此之后执行,item.attr的值为0。这就是“fieldName”是空字符串的原因,因为没有匹配项

我在评论中提到的修复似乎有效。根本的问题是,editorDataField属性仅在用户与combobox交互时设置


我通过在override public function set data()方法中设置它来解决这个问题。以这种方式,一旦用户触摸它,它就被设置

显示一些代码;这有点令人困惑。例如,您是否对DataGrid列使用labelFunction?还是组合框?你用的是火花组件还是光环组件?我已经用代码更新了帖子。不幸的是,我不知道如何让mxml进入代码模式,对不起。但感谢您的关注。打开括号/关闭括号按钮将格式化突出显示的代码。我正在测试一个修复程序,该修复程序目前似乎正在运行,并且很有意义。我添加这一行:this.attributeId=value.attr同上;到重写公共函数集数据方法。它之所以有意义,是因为当用户单击组合框但不进行任何更改时,将调用此方法。我将在原始帖子的代码中添加该行。
        private function getFieldName( item:Object, dgc:DataGridColumn ):String{
            var fieldName:String = '';

            /* At this point the lendersModel.fileAttributes collection is
               filtered based on the record type. We need to remove the filter
               so we can search the entire collection, not just the filtered subset. */
            lendersModel.fileAttributes.filterFunction = refreshFilter;
            lendersModel.fileAttributes.refresh();

            for each( var attrib:FileAttributeDTO in lendersModel.fileAttributes ){
                if( attrib.attribId == item.attribId )
                    fieldName = attrib.fileAttribDesc;
            }

            return fieldName;
        }
                if( rowCount != -1 && attribCombo.selectedItem != null )
                {                                                           
                    newFieldsDp[ rowCount ].fileAttribute.dataType = attribCombo.selectedItem.dataType;                                         
                    newFieldsDp[ rowCount ].fileAttribute.dataLength = attribCombo.selectedItem.dataLength; 
                    newFieldsDp[ rowCount ].fileAttribute.fileAttribDesc = attribCombo.selectedLabel;   
                    newFieldsDp[ rowCount ].dataLength = attribCombo.selectedItem.dataLength;       
                    newFieldsDp[ rowCount ].attribId = attribCombo.selectedItem.attribId;   
                }  
newFieldsDp[ rowCount ].attribId = attribCombo.selectedItem.attribId;