|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
In your demos for the tree view you are able to click on a node and select Delete from one of the options and I can't for the life of me get this working. Does the ContextControlID need to be for the node or for the tree view. If for the node, I load in my nodes dynamically ... any ideas how to get their runtime id?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, Check the sample's source code. It has nothing to do with ContextControlID. It handles the TreeView's ClientSideOnContextMenu to display the context menu with JavaScript. A client side TreeNode object would be passed to your JavaScript handler, from there you can get everything you need: http://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.TreeNode.htmlhttp://www.essentialobjects.com/ViewDoc.aspx?t=JSDoc.Public.NavigationItem.htmlThanks
|
|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
thanks... but still can't get it working... the javascript function is never called... I'm using Master Pages ..is there an issue here?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
No. The master page should not be an issue. Can you compare your code and our sample code and see if you can spot any difference?
|
|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
I can't see what's going on. Here's my code: I've just copied the context menu from the demo version.
<eo:TreeView runat="server" ID="TreePane2" AllowDragDrop="True" AutoCheckChildren="True" AutoUncheckChildren="True" AllowMultiSelect="True" ClientSideOnContextMenu="ShowContextMenu" AutoScroll="False" EnableKeyboardNavigation="True"> <LookNodes> <eo:TreeNode ItemID="_Default"> </eo:TreeNode> </LookNodes> <TopGroup Style-CssClass="treeView"> </TopGroup> </eo:TreeView> <eo:ContextMenu ID="Menu1" Width="144px" runat="server" ControlSkinID="None"> <TopGroup Style-CssText="cursor:hand;font-family:Verdana;font-size:11px;"> <Items> <eo:MenuItem Text-Html="Open"> </eo:MenuItem> <eo:MenuItem Text-Html="Delete"> </eo:MenuItem> <eo:MenuItem IsSeparator="True"> </eo:MenuItem> <eo:MenuItem Text-Html="Refresh"> </eo:MenuItem> </Items> </TopGroup> <LookItems> <eo:MenuItem IsSeparator="True" ItemID="_Separator" NormalStyle-CssText="background-color:#E0E0E0;height:1px;width:1px;"> </eo:MenuItem> <eo:MenuItem HoverStyle-CssText="color:#F7B00A;padding-left:5px;padding-right:5px;" ItemID="_Default" NormalStyle-CssText="padding-left:5px;padding-right:5px;"> <SubMenu ExpandEffect-Type="GlideTopToBottom" Style-CssText="border-right: #e0e0e0 1px solid; padding-right: 3px; border-top: #e0e0e0 1px solid; padding-left: 3px; font-size: 12px; padding-bottom: 3px; border-left: #e0e0e0 1px solid; cursor: hand; color: #606060; padding-top: 3px; border-bottom: #e0e0e0 1px solid; font-family: arial; background-color: #f7f8f9" CollapseEffect-Type="GlideTopToBottom" OffsetX="3" ShadowDepth="0" OffsetY="-4" ItemSpacing="5"> </SubMenu> </eo:MenuItem> </LookItems> </eo:ContextMenu>
and here's the Javascript : <asp:Content ID="MainMenuContent" ContentPlaceHolderID="MainMenu" runat="server">
<script type="text/javascript"> function ShowContextMenu(e, treeView, node) {alert('called show menu'); var menu = eo_GetObject("<%=Menu1.ClientID%>"); menu.getTopGroup().getItemByIndex(0).setText("Open '" + node.getText() + "'"); menu.getTopGroup().getItemByIndex(1).setText("Delete '" + node.getText() + "'"); eo_ShowContextMenu(e, "<%=Menu1.ClientID%>"); return true; }
it's located inside an asp content tag ... the "alert" is never hit .. I have checked the properties in design mode and can see no differences in the code.. in fact I've copied and pasted the treeview and context menu on to my page from the demo and this doesn't work .. so something is wrong with the wiring in my site ... but what it is..I'm at a loss... thanks for your quick replies by the way ... appreciated.
|
|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
ps. I'm creating the nodes dynamically in the code behind.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Do you have the page online so that we can take a look? If not, try to put everything into the same page (either without using master page, or put them inside the same content page), also try to use a few static nodes instead of dynamic nodes to see if it works. That should help you narrowing down to where the problem is.
|
|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
I'll try to expose the site some time today.. just a question: how is the context menu linked to the tree view? How does the tree view know it has a context menu request in order to fire the client side oncontextmenu event?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi,
The context menu is never directly linked to the TreeView. When user right clicks on a TreeNode, the TreeView calls the event handler you provided through ClientSideOnContextMenu (in your case 'ShowContextMenu'), inside that function you don't even have to display a context menu, you can do whatever you want, for example, display a message box, or even navigate to another site --- whatever can be done by JavaScript.
The code you copied from the demo, however, does call eo_ShowContextMenu to display a context menu. But like stated above, nothing is going to explode if you do not call eo_ShowContextMenu. So the TreeView and the ContextMenu is never directly linked together. The JavaScript handler you put in is what makes them work together.
Hope this helps.
Thanks
|
|
Rank: Member Groups: Member
Joined: 3/4/2008 Posts: 14
|
Hey there... I got this working ... I had some stray event hook up in my code behind....what a doofus... thanks for all your help ...
I have another question.. I've read that there is no way to delete a node from the tree client-side ... I want to have a delete option in the context menu... do I just use set disabled or set visible?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, If you don't need to delete feature, you can just delete the menu item and adjust the JavaScript code in ShowContextMenu (because the code tries to find the "Delete" menu item and update its item text). You will need to go over this in order to get familiar with our client side API: http://www.essentialobjects.com/ViewDoc.aspx?t=clientapi_howto.htmlAnother way is to put the whole TreeView inside a CallbackPanel to use AJAX call to delete the TreeNode on the server side. You would need to: 1. Place a CallbackPanel in the form. Then place the TreeView inside it; 2. Set the ContextMenu's RaisesServerEvent to true; 3. Edit the CallbackPanel's Triggers property to include the ContextMenu; 4. Handle the ContextMenu's ItemClick event on the server side and delete TreeNode there; Thanks
|
|