Categories | Question details Back To List | ||
context menu based on userdata I am trying to popup a context menu based on the user data I ahve a xml similart to this <tree id="0"> <item text="template" id="template~nextAddress~46"> <item text="no service udp-small-servers" id="nonEditableCommand~address~1" child="0"> <userdata name="nonEditableCommand"> no service udp-small-servers </userdata> </item> <item text="!" id="nonEditableCommand~address~2" child="0"> <userdata name="nonEditableCommand">!</userdata> </item> <item text="hostname uxx123456 " id="template~nextAddress~2~address~address" child="1"> <userdata name="editableCommand">uxx123456</userdata> <item text="hostname" id="nonEditableCommand~address~3" child="0"> <userdata name="nonEditableField" /> </item> <item text=" uxx123456 " id="nonEditableCommand~address~3" child="0"> <userdata name="editableField" /> </item> </item> ............ ............... </tree> I want to context menu based on the userdata clicked. meaning one context menu for noneditable command and a seperate context menu for Editable comman, based which is clicked I am trying to get userdata but I dont undertsand what should i write for name paramater. I wrote a function as follows function changeMenu(treeItemId) { var selctedUserData = null; var selctedNodeText = tree.getUserData(treeItemId,XXXXXXXXXXX); alert('you have clicked on::'+selctedNodeText); if (selctedNodeText == 'nonEditableCommand') { alert('context menu for nonEditableCommand'); aMenu.menu.showItem('NEC_Insert After'); aMenu.menu.showItem('NEC_Insert Before'); aMenu.menu.showItem('NEC_Delete'); } else if (selctedNodeText == 'editableCommand') { // alert('context menu for EditableCommand'); aMenu.menu.showItem('EC_Insert After'); aMenu.menu.showItem('EC_Insert Before'); aMenu.menu.showItem('EC_Delete'); } } can you suggest me wat should I write at XXXXXXX var selctedNodeText = tree.getUserData(treeItemId,XXXXXXXXXXX); to get the userdata name Thanks Answer posted by Support on Jan 18, 2008 01:43 With your current XML value it may be written as var selectedNodeText = (typeOf tree.getUserData(treeItemId,"nonEditableCommand") != "undefined")?"nonEditableCommand":"editableCommand"; but its quite a complex on my opinion, if you will slightly update used XML it may be used much more clean <item text="hostname" id="nonEditableCommand~address~3" child="0"> <userdata name="cMenu" >nonEditableField</userdata> </item> <item text=" uxx123456 " id="nonEditableCommand~address~3" child="0"> <userdata name="cMenu">editableField</userdata> </item> var selectedNodeText = tree.getUserData(treeItemId,"cMenu"); |