|
Rank: Advanced Member Groups: Member
Joined: 8/21/2008 Posts: 37
|
Hi,
I've got 3 columns, View, Edit and delete in EO.Grid. On clicking delete, I want the confirmation from the server side. On clicking "Yes", I'm writing code to delete the record from database in Grid_ItemCommand.
In ASP.net DataGrid control, we've got ItemDatabound event. Where you can write the code for confirmation. In EO.Grid, I found code for confirmation. But that will delete the record from EO.Grid and not from database.
Please suggest me how to add the confirmation in server end when delete button is clicked.
Thanks in advance.
Raghav
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi,
Our Grid works very differently than ASP.NET DataGrid. ASP.NET DataGrid goes back to the server for every action (for example, delete), and our Grid does not do so. When you delete a record from our Grid, the Grid delete the row on the client side and "remembers" this until the page goes back to the server, at which time you can then actually delete the row from your database. The advantage of this model is that user will be able to delete multiple rows without going back to the server every time.
The confirmation code you found is probably for confirming deleting on the client side. When the page is posted back to the server side (either by the Grid itself or somebody else, for example, a Button), you can then handle the Grid's ItemsDeleted event to update your database.
Hope this helps.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 8/21/2008 Posts: 37
|
Hi,
Thanks a lot for quick help.
Regards, Raghav
|
|
Rank: Advanced Member Groups: Member
Joined: 8/21/2008 Posts: 37
|
Hi,
Could you please clarify the below scenario. If a user deletes multiple rows from the Grid and closes the window. The itemsDeleted event will not be fired and the records will not be deleted. So when user see the grid next time, the records will be present. Then how the Itemsdeleted event is fired. How do I post back the page to server side without the help of button. How to handle the Items deleted event.
It would be great, if you would help me in this matter. As I'm stuck with this thing. With this solution I can change all ASP.net datagrid to EO.Grid in my application.
Thanks once again.
Regards, Raghav
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,193
|
Hi, In the case user delete data without "submiting" it, it would be like user changed something in a textbox without clicking "Save" button. The change will be lost. Our Grid does allow you to go back to the server every time when user delete a row, even though that's not the default behavior. You would start from this sample: http://www.essentialobjects.com/Demo/Default.aspx?path=Grid\_i1\_i9Then change the code that handles the delete to something like this:
Code: JavaScript
function OnItemDelete(grid, itemIndex, colIndex, commandName)
{
//Ask user to confirm the delete
if (window.confirm("Are you sure you want to delete this row?"))
grid.raiseItemCommandEvent(itemIndex, "anything_you_like");
}
raiseItemCommandEvent will post back the page (similar to user clicking a button). In addition, it will also raise the Grid's ItemCommand event on the server side. There you can delete the record from your database, repopulate the Grid --- very much the same way as what you do with ASP.NET DataGrid. Hope this helps. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 8/21/2008 Posts: 37
|
Hi, It worked!!! Thanks a lot. Regards, Raghav
|
|