This is a migrated thread and some comments may be shown as answers.

Cancel Postback in OnClientNodeEdited Event

4 Answers 62 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Marbry
Top achievements
Rank 1
Marbry asked on 06 Jun 2012, 03:16 PM
Is there a way to cancel the postback from the OnClientNodeEdited event handler for the OnNodeEdit server event?  I need to be able to selectively cancel this postback in the client code, but I haven't found a way that works yet.

There is no set_cancel() in the arguments passed.  Setting cancelBubble and returnValue on the window.event don't work.  Calling node.endEdit() or _cancelEvent() both throw an error.

I even tried setting the node's _originalText and _originalTextHtml to its _text value to see if it would keep it from being detected as modified.

Any suggestions would be welcome.

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Jun 2012, 05:29 AM
Hi Marbry,

You can cancel OnNodeEdit sever side event in the OnClientNodeEditing as follows.

JS:
<script type="text/javascript">
    function OnClientNodeEditing(sender, args)
    {
        args.set_cancel(true);
    }
</script>

Hope this helps.

Thanks,
Princy.
0
Marbry
Top achievements
Rank 1
answered on 07 Jun 2012, 06:27 AM
Well no, as I stated above, there is no set_cancel() method on the arguments for that handler for some reason.
0
Princy
Top achievements
Rank 2
answered on 07 Jun 2012, 08:52 AM
Hi Marbry,

The OnClientNodeEdited event occurs when a node has been edited by the end user. It is not possible to cancel the serverside postback from OnClientNodeEdited event. The OnClientNodeEditing event occurs after the user has finished editing but before the OnClientNodeEdited event. If you want to cancel the postback you can cancel that from  OnClientNodeEditing event as I suggested above. Please take a look into the following documentations for more information.
OnClientNodeEditing
OnClientNodeEdited

Please elaborate your scenario if it doesn't help so that I can suggest a way.

Thanks,
Princy.
0
Marbry
Top achievements
Rank 1
answered on 07 Jun 2012, 12:54 PM
Ok, that's what I get for reading that on my phone.

Yes, I think that's going to work.  Although it does require setting the _originalText properties so that it doesn't just reset the visible node on the client to the previous value.

Thanks!
Tags
TreeView
Asked by
Marbry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Marbry
Top achievements
Rank 1
Share this question
or