Welcome Guest Search | Active Topics | Sign In | Register

TreeView/ContextMenu JavaScript Options
Mackin
Posted: Tuesday, December 22, 2009 11:30:55 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
How can I display different ContextMenu's depending on the different types of TreeNodes. With Javascript I can get the node text by node.getText() or the value by node.getValue() but how can I get the ItemID? The ItemID should contain my different Looks so that I can determine what ContextMenu to display.
eo_support
Posted: Tuesday, December 22, 2009 11:32:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Mackin
Posted: Tuesday, December 22, 2009 11:39:02 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Then why do I get undefined in the alert box with this?


<script type="text/javascript">
function ShowContextMenu(e, treeView, node) {
//Get the context menu object
var menu = eo_GetObject("<%=eo_menu_Content.ClientID%>");

alert(node.getItemId());


eo_ShowContextMenu(e, "<%=eo_menu_Content.ClientID%>");

return true;
}
function MenuItemClickHandler(e, info) {
window.alert("Menu item '" +
info.getItem().getValue() + "' clicked.");
}
</script>
Mackin
Posted: Tuesday, December 22, 2009 1:12:26 PM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Sorrr to bug you again but do you have any solution for this yet?
eo_support
Posted: Tuesday, December 22, 2009 1:31:41 PM
Rank: Administration
Groups: Administration

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

We are not aware of any problem with getItemId function. It should return whatever ItemID value you set on the server side. If the node has ItemID set, getItemId will return the set value; otherwise it has nothing to return and you get undefined.

Thanks

Mackin
Posted: Tuesday, December 22, 2009 1:39:49 PM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Thank You for your help I did not know I had to bind something to that Property. After Binding it works fine
Mackin
Posted: Wednesday, December 23, 2009 9:29:05 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Ok yes what you said worked however now that I'm also Binding the ItemID so that I can read it in the JavaScript and display my correct ContextMenu I can no longer get the OnItemClick or OnItemMove to work in the TreeView. If I comment out the DataBinding of the ItemID then the OnItemMove works and the OnItemClick works.

Is there any way that with the

function ShowContextMenu(e, treeView, node)

to read the LookID or other properties that will not break the one action for another?
eo_support
Posted: Wednesday, December 23, 2009 9:34:17 AM
Rank: Administration
Groups: Administration

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

Please see here for a list of available methods on the client side:

http://doc.essentialobjects.com/library/1/jsdoc.public.navigationitem.aspx
http://doc.essentialobjects.com/library/1/jsdoc.public.menuitem.aspx

Most people use Value property because it is not used by the control in any way (unlike ItemID which is being used to create node path). I don't believe you can get LookID from client side.

Thanks
Mackin
Posted: Wednesday, December 23, 2009 11:51:00 AM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
I found that the property axp in the node has what I need. Do you change these properties with your builds or am I safe to use this.


<script type="text/javascript">
function ShowContextMenu(e, treeView, node) {
//Get the context menu object
var ItemId = node['axp'];
switch (ItemId)
{
case "_SubmittedList":
eo_ShowContextMenu(e, "<%=eo_menu_SubmittedList.ClientID%>");
break
case "_LockedList":
eo_ShowContextMenu(e, "<%=eo_menu_LockedList.ClientID%>");
break
case "_DefaultList":
eo_ShowContextMenu(e, "<%=eo_menu_DefaultList.ClientID%>");
break
case "_Default":
eo_ShowContextMenu(e, "<%=eo_menu_Default.ClientID%>");
break
case "_Root":
eo_ShowContextMenu(e, "<%=eo_menu_Root.ClientID%>");
break
default:
alert('Sorry no menu for this group');
}
return true;
}
</script>


eo_support
Posted: Wednesday, December 23, 2009 3:17:11 PM
Rank: Administration
Groups: Administration

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

You don't want to rely on that because the name "axp" can change between every build. We will see if we can add it as a documented function but please understand that we have to be very careful about adding things because we can't just add everything everyone wanted.

Thanks!
Mackin
Posted: Wednesday, December 23, 2009 4:12:27 PM
Rank: Advanced Member
Groups: Member

Joined: 6/1/2007
Posts: 31
Yes I understand that you can not add something every time some requests. Please let me know if you do add this in the next build though
eo_support
Posted: Wednesday, December 23, 2009 4:30:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
will do.


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.