Welcome Guest Search | Active Topics | Sign In | Register

GridView Delete Button to show dialog after option to cancel delete Options
Colin
Posted: Saturday, February 7, 2009 1:33:42 PM
Rank: Advanced Member
Groups: Member

Joined: 2/1/2008
Posts: 35
Hi,

I have a modal dialog that has a dropdown that needs to be selected giving the reason for deletion appearing upon the gridview delete button being clicked but the record has already been deleted.

I need a way to first give the option to cancel the deletion and then if confirmation to delete is given, delete the record and open the dialog and complete the dropdown selection. I can't use a cancel button on the dialog because the record has already gone.

I am using OnClientClick="eo_GetObject('Dialog1').show(true);" on the delete button but I guess I need to use something like return confirm('Are you sure you want etc.'); and then on True, fire the eo_getObject but not quite sure how to do all this onclientclick. I presume I need something like:

<script LANGUAGE="JavaScript">
<!--
function confirmDelete()
{
var agree=confirm("Are you sure you wish to delete?");
if (agree)
return true ;
eo_GetObject('Dialog1').show(true);
else
return false ;
}
// -->
</script>


If it's possible to get the code to do this correctly and know exactly what to add onclientclick I would be very greatful

Thanks.
eo_support
Posted: Sunday, February 8, 2009 11:58:39 AM
Rank: Administration
Groups: Administration

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

I am not sure if I understand your question correctly. The key for dialog is Dialog.show is always non-blocking. So you can not rely on "canceling a dialog" to return false like you do with confirm. On the contrary, you should rely on "confirming a dialog" to carry out additional action. So the whole process is always two steps: The first step displays the dialog, the second step carries our any additional action you would like when user confirms the dialog.

In the case of the Grid deleting button, this means the delete button’s OnClickClick should display the dialog but always return false so that the delete is not carried out at this stage (step 1). The actual deletion code should be a call to __doPostBack and it should be moved into the dialog’s ClientSideOnAccept handler. Since your original code does not call __doPostBack directly, you may wish to use the debugger to find out the exact parameters the GridView uses to call __doPostBack so that you can simulate the same action in your code.

Hope this helps.

Thanks!
Colin
Posted: Tuesday, February 10, 2009 4:18:36 AM
Rank: Advanced Member
Groups: Member

Joined: 2/1/2008
Posts: 35
Hi,
For info in case anybody is interested, I was missing a {

<script type="text/javascript">
<!--
function confirmDelete()
{
var answer = confirm("Confirm Delete?")
if (answer) {
eo_GetObject('Dialog1').show(true);
}
else {
return false;
}
}
//-->
</script>

Called by

OnClientClick="return confirmDelete()"


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.