Welcome Guest Search | Active Topics | Sign In | Register

return value of ClientSideBeforeEditItem event Options
the kid
Posted: Wednesday, October 22, 2008 1:03:24 AM
Rank: Member
Groups: Member

Joined: 7/29/2008
Posts: 14
How can I check the return value of the ClientSideBeforeEditItem event? I want to know if user cancel editing row and perform some action in that case.

Thanks!
eo_support
Posted: Wednesday, October 22, 2008 4:33:34 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

There isn't an ClientSideBeforeEditItem. I am assuming that you mean CustomColumn.ClientSideBeginEdit. But in any case, all ClientSideXXXX events are a function provided by you. In the case of ClientSideBeginEdit, you would simply do whatever you want to do inside the function you provided and then return false to cancel the edit.

Thanks
the kid
Posted: Wednesday, October 22, 2008 5:37:01 AM
Rank: Member
Groups: Member

Joined: 7/29/2008
Posts: 14
Yes, there is. It is introduced in 6.0.40 version, so it is new feature:

http://www.essentialobjects.com/doc/eo.web.grid.clientsidebeforeedititem.html

I have declared events in the grid:

Code: HTML/ASPX
<eo:Grid ID="Grid2" runat="server" BorderColor="#828790" BorderWidth="1px" 
	ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" 
	ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24"
	FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" FullRowMode="true"
	Font-Overline="False" Font-Size="9pt" Font-Strikeout="False"				Font-Underline="False" GridLineColor="240, 240, 240" GridLines="Both"
	Height="500px" Width="880px" RunningMode="Client" AllowNewItem="False" 
	ClientSideOnLoad="Grid2_OnLoad" ClientSideBeforeEditItem="Grid2_BeforeEditItem" ClientSideAfterEditItem="Grid2_AfterEditItem">


and created appropriate javascript functions:

Code: JavaScript
var EditItemNumber = -1;
function Grid2_BeforeEditItem(item) {
	EditItemNumber = item.getIndex();
}

function Grid2_AfterEditItem(item) {
	EditItemNumber = -1;
}


As you can see from javascript code I want to set EditItemNumber when user enters edit mode and reset EditItemNumber to -1 when user exits edit mode. But I can't reset EditItemNumber when user for example pres esc key. In that case the Grid2_AfterEditItem is not triggered. Is there a way how to reset that var when user cancels editing item?
eo_support
Posted: Wednesday, October 22, 2008 5:54:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

ClientSideAfterItemEdit is only called when an item has been updated. For example, if you have a EditCommandColumn and you put the row into edit mode by clicking "Edit". If you click "Update" to exit edit mode, then ClientSideAfterItemEdit will be called. However if you click "Cancel" to exit edit mode, then it will not be called.

There does pose a void which causes you not able to track the current edit item. We will see if we can add the following:

1. Add a function on the Grid so that you can get the current edit item directly. Similar to Grid.getSelectedItem;
2. Add an additional parameter to ClientSideAfterItemEdit so that the function is called both on "Update" and "Cancel". The additional parameter would be used to distinguish whether it was an update or cancel;

We will post again as soon as we have any update on that.

Thanks!
eo_support
Posted: Tuesday, October 28, 2008 6:51:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

We have posted a new build that added:

1. getEditItem and getEditCell on the client side Grid object;

2. An additional parameter for ClientSideAfterItemEdit to indicate whether the function was called by "update" or "cancel";

Please see your private message for download location.

Thanks!
the kid
Posted: Wednesday, October 29, 2008 3:34:34 AM
Rank: Member
Groups: Member

Joined: 7/29/2008
Posts: 14
Yes! That's it! Thank you! Thank you! Thank you!

BUT!

You have to be very careful regard this implementation. Now ClientSideAfterEditItem event will be triggered either user updates or cancels grid item. I suppose most programmers call web service method for saving some data regardless of user action because (untill now) this event has been triggered only in the case if user updates row and now all programmers have to check the second argument and call that method only in case if user updates row.
Sorry again because my English. I hope this warning is clear.
eo_support
Posted: Wednesday, October 29, 2008 5:43:03 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Thank you very much for your excellent suggestion!

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.