You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by João Fernandes <jo...@gmail.com> on 2012/11/28 15:42:19 UTC

Spark Datagrid editor session ending

Hi, I've noticed that spark datagrid doesn't support ITEM_EDIT_END  only
Session_save and session_cancel which is different from what mx:Datagrid
behavior. With ITEM_EDIT_END (which should be "ITEM_EDIT_END"), we have the
possibility to validate our data outside of our itemEditor and call
preventDefault() to prevent the item editor to be destroyed which doesn't
seem to be possible right now with the current implementation. My question
is, should the spark datagrid support this case scenario? If so I'll create
a ticket and create the patches necessary to fix it.

-- 

João Fernandes

Re: Spark Datagrid editor session ending

Posted by João Fernandes <jo...@gmail.com>.
On 28 November 2012 17:42, Alex Harui <ah...@adobe.com> wrote:

>  modify DG to dispatch such an event.
> Another is to provide an alternate item editor that dispatches the event
> from the DG in its save() method.
>
> In the new framework I am rewriting, I would argue for the second option.
> The DG should not waste time dispatching events just-in-case.  You can turn
> on that capability by choosing a new default renderer.
>

Thanks Alex, in my opinion I would implement the event the same way SAVE
and CANCEL are handled currently but in the future I agree it should be
handled by the ItemEditor instance itself.

I'll log a bug later today with a patch to it.
-- 

João Fernandes

Re: Spark Datagrid editor session ending

Posted by Alex Harui <ah...@adobe.com>.


On 11/28/12 8:58 AM, "João Fernandes" <jo...@gmail.com>
wrote:

> Carol but that's the point, with mx:datagrid you can prevent any save()
> using an event listener and without extending the default itemEditor by
> listening to the session_edit_end and calling preventDefault on the event
> dispatched. With spark Datagrid it's not possible. It doesn't make sense
> for each validation I would have to create a new item editor just for
> overriding the save method to implement my business logic.
I argued for an event back in the day but lost.  You shouldn't have to
customize an item editor to deal with the lifecycle of editing.  Events are
easier to hook up to, even if it is a bit less object-oriented.

Now, I see two options:  One is to modify DG to dispatch such an event.
Another is to provide an alternate item editor that dispatches the event
from the DG in its save() method.

In the new framework I am rewriting, I would argue for the second option.
The DG should not waste time dispatching events just-in-case.  You can turn
on that capability by choosing a new default renderer.

But for the legacy code base, we would probably choose option 1.

> 
> On 28 November 2012 16:54, Carol Frampton <cf...@adobe.com> wrote:
> 
>>  think you override IGridItemEditor save() to do what you want.
>> 
>> Carol
>> 
> 
> 

-- 
Alex Harui
Flex SDK Team
Adobe Systems, Inc.
http://blogs.adobe.com/aharui


Re: Spark Datagrid editor session ending

Posted by João Fernandes <jo...@gmail.com>.
Carol but that's the point, with mx:datagrid you can prevent any save()
using an event listener and without extending the default itemEditor by
listening to the session_edit_end and calling preventDefault on the event
dispatched. With spark Datagrid it's not possible. It doesn't make sense
for each validation I would have to create a new item editor just for
overriding the save method to implement my business logic.

On 28 November 2012 16:54, Carol Frampton <cf...@adobe.com> wrote:

>  think you override IGridItemEditor save() to do what you want.
>
> Carol
>



-- 

João Fernandes

Re: Spark Datagrid editor session ending

Posted by Carol Frampton <cf...@adobe.com>.
I think you override IGridItemEditor save() to do what you want.

Carol

On 11/28/12 11 :29AM, "João Fernandes"
<jo...@gmail.com> wrote:

>Carol, with mx:Datagrid you can prevent a edit session from ending by
>calling preventDefault on sessionEditEnd event. There is no way to achieve
>the same with the spark datagrid. Being able to capture the sessionEditEnd
>allow me to use a generic item editor and instead of implementing
>validate() in the itemEditor, I can listen to the sessionEditEnd, once the
>event is fired, it willl run my listener function and call
>preventDefault()
>if my data isn't valid, which prevents the session to be terminated.
>
>
>On 28 November 2012 16:18, Carol Frampton <cf...@adobe.com> wrote:
>
>> not quite sure what you are trying to do but I bet you can currently
>> do it with the existing Spark DataGrid.  You may have to do it
>> differently.  Have you looked at [1]?  Would it be possible to provide a
>> small example?
>>
>
>
>
>-- 
>
>João Fernandes


Re: Spark Datagrid editor session ending

Posted by João Fernandes <jo...@gmail.com>.
Carol, with mx:Datagrid you can prevent a edit session from ending by
calling preventDefault on sessionEditEnd event. There is no way to achieve
the same with the spark datagrid. Being able to capture the sessionEditEnd
allow me to use a generic item editor and instead of implementing
validate() in the itemEditor, I can listen to the sessionEditEnd, once the
event is fired, it willl run my listener function and call preventDefault()
if my data isn't valid, which prevents the session to be terminated.


On 28 November 2012 16:18, Carol Frampton <cf...@adobe.com> wrote:

> not quite sure what you are trying to do but I bet you can currently
> do it with the existing Spark DataGrid.  You may have to do it
> differently.  Have you looked at [1]?  Would it be possible to provide a
> small example?
>



-- 

João Fernandes

Re: Spark Datagrid editor session ending

Posted by Carol Frampton <cf...@adobe.com>.
I'm not quite sure what you are trying to do but I bet you can currently
do it with the existing Spark DataGrid.  You may have to do it
differently.  Have you looked at [1]?  Would it be possible to provide a
small example?

Carol

[1] 
http://help.adobe.com/en_US/flex/using/WS0ab2a460655f2dc3-427f401412c60d04d
ca-7ff3.html

On 11/28/12 9 :42AM, "João Fernandes"
<jo...@gmail.com> wrote:

>Hi, I've noticed that spark datagrid doesn't support ITEM_EDIT_END  only
>Session_save and session_cancel which is different from what mx:Datagrid
>behavior. With ITEM_EDIT_END (which should be "ITEM_EDIT_END"), we have
>the
>possibility to validate our data outside of our itemEditor and call
>preventDefault() to prevent the item editor to be destroyed which doesn't
>seem to be possible right now with the current implementation. My question
>is, should the spark datagrid support this case scenario? If so I'll
>create
>a ticket and create the patches necessary to fix it.
>
>-- 
>
>João Fernandes