Welcome Guest Search | Active Topics | Sign In | Register

DeleteCommandColumn with confirmation Options
Steve
Posted: Tuesday, March 13, 2012 2:56:25 PM
Rank: Member
Groups: Member

Joined: 12/2/2010
Posts: 10
I have implemented an EO grid with a DeleteCommandColumn which works to delete items as desired. I want to add an "are you sure" dialog box to get user confirmation before deleting the item. I also want to be able to disable the button (or cancel the event) based on the contents of other columns.

I added a handler for ClientSideOnItemCommand but this event doesn't appear to fire in the case of a click on the delete command button. What is the proper way to handle this situation?
eo_support
Posted: Tuesday, March 13, 2012 4:05:25 PM
Rank: Administration
Groups: Administration

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

To display a confirmation dialog box, please try to use a ButtonColumn as demonstrated here:

http://demo.essentialobjects.com/Demos/Grid/Features/Deleting%20with%20Confirmation/Demo.aspx

All the built-in commands (Edit, Delete, Update and Cancel) bypasses ClientSideOnItemCommand. ClientSideOnItemCommand is for custom "generic" commands only. For a ButtonCommand, your handler will be responsible to actually carry out the deletion (see the sample code for how to do this). So if you wish to cancel the delete, just do nothing in your handler, which effective disable the command.

If you wish to have the disabled command to look differently (for example, grayed out), then you must supply a different style for that cell. For example, the following code applies CSS rule "disabled_button" to the third cell of the second row:

Code: CSS
.disabled_button
{
	padding-top: 2px;
	padding-left: 8px;
}                        

.disabled_button a
{
	color: gray;
	text-decoration: none;
}
.disabled_button a:hover
{
	color: gray;
	text-decoration: none;
}
.disabled_button a:visited
{
	color: gray;
	text-decoration: none;
}


Code: JavaScript
var grid = eo_GetObject("Grid1");
grid.getItem(1).getCell(2).overrideStyle("disabled_button");


You can also apply the style through data binding. See here for more details:

http://demo.essentialobjects.com/Demos/Grid/Features/Conditional%20Formatting%20-%20Cell%20Based/Demo.aspx

Hope this helps. Please let us know if you still have any questions.

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.