简体   繁体   中英

Please explain why i am getting the following error when I use itemrenderer and itemeditor components in the datagrid column

Code:

<mx:DataGridColumn id="a" headerText="Notes" dataField="a" width="200" visible="true" editable="false" wordWrap="true" editorDataField="text">

<mx:itemRenderer>
    <mx:Component>
        <mx:HBox>
            <mx:Text width="100%" height="100%"/>
        </mx:HBox>
    </mx:Component>
</mx:itemRenderer>
<mx:itemEditor>
    <mx:Component>
        <mx:HBox>
            <renderers:EditorTextRenderer width="100%" />
        </mx:HBox>
    </mx:Component>
</mx:itemEditor> 

ErrorStackTrace: ReferenceError: Error #1069: Property text not found on a.mxml.a_inlineComponent3 and there is no default value.

I suppose, your custom component EditorTextRenderer should contain property text . Or you must set editorDataField to that property, which is responsable for editing. For more details read this .

A simple inline item editor contains a single control that supports the data property. Flex automatically copies the current cell data to the item renderer or item editor, and copies the new cell data back to the list control based on the value of the editorDataField property

First, I don't recommend using inline item renderers/editors. It makes for sloppy code and stops you from reusing the renderers elsewhere (which is kind of the whole point; also, if in separate files it would be easier to debug). Second, I believe that problem lies in the EditorTextRenderer which probably already it's own renderer and doesn't support the 'text' attribute. I think what you want to do is this:

<mx:itemEditor>
<renderers:EditorTextRenderer width="100%" />
   </mx:itemEditor> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM