Hi,
While bubbling may seem like a good idea, it has been pointed out in a
couple of other email threads that it has its perils, too. With that in
mind, I modified the TodoListExample in the FlexJS examples/flexjs
directory.
This example has a list with itemRenderers that have checkboxes in them.
Checking them on and off updates a count outside of the list and
maintained in the application-wide data model.
TodoListController is responsible for updating the model. It does this my
listening for special events from the initialView which it sets up when
the view is created.
If you look at the TodoListView, you'll see this MXML
<js:List id="todoList"
itemRenderer="sample.todo.renderers.TodoItemRenderer"
dataProvider="{TodoListModel(applicationModel).todos}"
width="100%" height="400">
<js:beads>
<js:DataItemRendererFactoryForArrayData
itemRendererCreated="handleRendererCreated(event)" />
</js:beads>
</js:List>
where the List is set up with an instance of the
DataItemRendererFactoryForArrayData (the one for ArrayListData does the
same thing) so that its itemRendererCreated event can be used to capture
when each itemRenderer is created. That event handler then sets up
listeners for the check box on the itemRenderer. When the checkbox change
is detected, the view dispatches the special events the TodoListController
is listening for.
Basically, for FlexJS, when you want to listen for events from
itemRenderers, use the factory to capture the creation of the itemRenderer
and set up your event listeners on the itemRenderer's elements.
I hope this helps.
Peter Ent
Adobe Systems/Apache Flex Project
On 9/26/16, 1:21 AM, "Alex Harui" <[email protected]> wrote:
>Peter will hopefully provide an answer on Monday. The old Flex pattern of
>bubbling an event from an item renderer is really not a good practice as
>has been discussed recently on the dev@ list. For FlexJS we are
>suggesting folks use a custom factory and attach listeners as they get
>created. I don't recall off-hand whether that code got committed or not.
>
>-Alex
>
>On 9/24/16, 9:45 PM, "Vulcansoft" <[email protected]> wrote:
>
>>I meant to listen for the change event of the checkbox, not the grid.
>>You¹ll need an itemrenderer or itemeditor for that.
>>
>>-Christian
>>
>>
>>> On Sep 25, 2016, at 5:40 AM, PKumar <[email protected]> wrote:
>>>
>>> I checked it and found strange behavior of event. DataGrid change event
>>> behaving differently on Flash & JS side. If my render is dispatching
>>> "change" event then only it is working but if my render is dispatching
>>> customevent then it is not working.
>>>
>>>
>>>
>>> -----
>>> Regards,
>>> Prashant
>>> --
>>> View this message in context:
>>>http://apache-flex-users.2333346.n4.nabble.com/FlexJS-Dispatching-event-
>>>f
>>>rom-ItemRenderer-tp13612p13618.html
>>> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>>
>