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

[Solved] OnContextMenuItemClick override 'return false'

7 Answers 158 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Relative
Top achievements
Rank 1
Relative asked on 07 May 2008, 01:51 PM
Hi,

I am porting from the old controls. Here we had the eqivilant event of OnClientContextMenuItemClicking  in the separate RadMenu assigned to this javascript functon:

         if (menuText == "Add Page"
                { 
                    windowMode = 'ADDNEW'
                    var oWnd = radopen ("customPagesAdd.aspx?parent_id=" + pageID, "editWindow"); 
                    oWnd.SetSize (740, 400); 
                    oWnd.Center(); 
                    oWnd.SetTitle ("Add New Page"
                  return false
                } 


We also have assigned OnContextMenuItemClick which points to a server side function.
Before, the return false on the client would stop the postback from occuring and the OnContextMenuItemClick from firing
(we only want it to occur when the menu text is matched to something else)

Now it fires the clientside event (good) and then does the postback for serverside fucntion (bad)

How can I stop the postback?

Thanks,

Leon.


7 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 May 2008, 02:34 PM
Hi Leon Mills,

You should use the set_cancel method of the event arguments as shown in the following help article:
The OnClientContextMenuItemClicking event

Hope this helps.

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Relative
Top achievements
Rank 1
answered on 07 May 2008, 02:43 PM
Excellent - is this a change or should we have been using setCanel in the first place?

L.

0
Nikolay
Telerik team
answered on 07 May 2008, 02:46 PM
Hello Leon Mills,

Yes, this is a change. The new client-side API is documented  in the "Client-Side Programming" section of the help manual.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Puzsol
Top achievements
Rank 1
answered on 11 Jun 2008, 01:45 AM
I tried this code with the OnClientContextMenuItemClicking event of the tree-view.... only I found that if I call set_cancel(true), that the menu says, and the OnClientContextMenuItemClicked event doesn't fire... so it cancels all events, not just the postback (OnContextMenuItemClick) that I was wanting to cancel... am I missing something here?

Thanks
0
Puzsol
Top achievements
Rank 1
answered on 11 Jun 2008, 02:29 AM
I may have answered my own question....

In the on context menu clicking event, I set the 
TreeView._postBackOnContextMenuItemClick property to false... this seems to stop the postback, while if I set it to true, it continues and does a postback...

Is this a valid method of achieving the result I am after?
Is there some function that I missed that would do the same thing?

Thank you

Andrew
0
Erjan Gavalji
Telerik team
answered on 13 Jun 2008, 01:49 PM
Hi Andrew,

To disable the postback for a RadTreeNode you can set its PostBack property to false. While basically there is no problem to use the _postBackOnContextMenuItemClick member, it is considered "private" as per the ASP.NET Ajax convention and is a subject to change. We don't encourage the usage of private members, as a later version of the control can have a change in this logic, breaking your application during an upgrade.

Let me know if I understood what you need.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Puzsol
Top achievements
Rank 1
answered on 17 Jun 2008, 01:14 AM
Not quite what I was after... as in the menuClicking event I only wanted to stop the postback for the context menu, not everything... though I guess if I turned it back on in the menuClicked event, then it would most likely not interfere with other postbacks.

It's somewhat irrelevant now, as I eventually found that with all the refreshing required, that I may as well perform a postback to do the actions I was attempting to complete at the client end anyway... much simpler logic.

Thanks
Tags
TreeView
Asked by
Relative
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Relative
Top achievements
Rank 1
Puzsol
Top achievements
Rank 1
Erjan Gavalji
Telerik team
Share this question
or