So it looks as though a "standard" grid column (i.e. one with dataField set)
relies on a PropertyChangeEvent.

i.e. if I have

                        <mx:DataGridColumn  headerText="Dbg" width="26"
dataField="dirtyFlag"
                            />

Then my custom setter must have:

        [Bindable(event="dirtyFlagChanged")]
        public function get dirtyFlag():Boolean {
            return _dirtyFlag;
        }

        public function set dirtyFlag(value:Boolean):void {
            _dirtyFlag = value;
            dispatchEvent(new Event("dirtyFlagChanged"));

dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"dirtyFlag", false,
value));
        }

which sort of undermines the performance benefits of custom getters and
setters, I would think.
Whereas if I have an item renderer, the property change event is not
necessary because the custom renderer sets up a binding
eg. {data.dirtyFlag}

Rather than depend on this, it's probably best for me to ensure that
itemUpdated() gets called.
Most educational!


On Wed, Dec 23, 2009 at 1:51 PM, Richard Rodseth <[email protected]> wrote:

> I haven't ever dug into the basic mechanism here (never needed to). Does
> the event that my custom setter dispatches have to be a PropertyChangeEvent?
> Who's listening to it? Is the Grid or GridColumn or default renderer
> observing the collection only, or the item within the collection (via set
> data)? I'll poke around, but any pointers would be appreciated.
>
>
> On Wed, Dec 23, 2009 at 12:03 PM, Alex Harui <[email protected]> wrote:
>
>>
>>
>>  Yeah, sorry.  I was trying to read the code from the preview window.
>>
>>
>>
>> Sounds like the data object is getting changed in a way that there is no
>> collectionevent.
>>
>>
>>
>> Alex Harui
>>
>> Flex SDK Developer
>>
>> Adobe Systems Inc. <http://www.adobe.com/>
>>
>> Blog: http://blogs.adobe.com/aharui
>>
>>
>>
>> *From:* [email protected] [mailto:[email protected]] *On
>> Behalf Of *Richard Rodseth
>> *Sent:* Wednesday, December 23, 2009 11:51 AM
>> *To:* [email protected]
>> *Subject:* Re: [flexcoders] DataGrid vs custom getter
>>
>>
>>
>>
>>
>> Hi Alex,
>>
>> I showed the setter for "editedName" which dispatches "editedNameChanged".
>> Similarly, the setter for "role" dispatches "roleChanged".
>> My understanding is that a getter ("name") in this case, can have multiple
>> [Bindable] declarations as in my example.
>>
>>  On Wed, Dec 23, 2009 at 11:43 AM, Alex Harui <[email protected]> wrote:
>>
>>
>>
>> I don’t see the bindable events getting dispatched.
>>
>>
>>
>> Alex Harui
>>
>> Flex SDK Developer
>>
>> Adobe Systems Inc. <http://www.adobe.com/>
>>
>> Blog: http://blogs.adobe.com/aharui
>>
>>
>>
>> *From:* [email protected] [mailto:[email protected]] *On
>> Behalf Of *Richard Rodseth
>> *Sent:* Wednesday, December 23, 2009 11:39 AM
>> *To:* [email protected]
>> *Subject:* [flexcoders] DataGrid vs custom getter
>>
>>
>>
>>
>>
>> I have a DataGrid column which is not updating when the relevant property
>> is changed, *unless* I have a custom itemrenderer, which I no longer have
>> any other need for.
>>
>> The data provider contains objects with the following properties:
>>
>>         [Bindable(event="editedNameChanged")]
>>         [Bindable(event="roleChanged")]
>>         public function get name():String {
>>             if (_editedName) {
>>                 return _editedName;
>>             } else {
>>                 return role.name;
>>             }
>>         }
>>
>>         public function set editedName(value:String):void {
>>             _editedName = value;
>>             dispatchEvent(new Event("editedNameChanged"));
>>         }
>>
>> If I use an itemrenderer containing a
>> <mx:Label text="{data.name}"/>
>> the column updates correctly when editedName is changed, but if I just set
>> the grid column dataField to "name", the name does not update when
>> editedName is changed.
>> Something silly I'm forgetting?
>>
>>
>>
>>   
>>
>
>

Reply via email to