aem Posted September 24, 2019 Share Posted September 24, 2019 We use the tuniTreeMenu hooked to tuniMenuItems extensively - works great. I want to be able to disable all the items a user doesn't have the right to access at startup. But assigning values to 'enabled' has no effect. Possible? Anyway, I did find nice code in this group that lets me HIDE individual treemenu items. It works great for Top level items, but not for child items. Hmm. Even if I fully expand the tree items and then execute the code, sub-items don't seem to be affected. Here is an example test of mine: welcome1.enabled := False; //a top level item - BECOMES HIDDEN personalchecks1.visible:=false; //a second level child item - NO CHANGE with UniTreeMenu1 do begin _llist := ''; for I := 0 to SourceMenu.Items.Count-1 do if not SourceMenu.Items.Visible then if _llist='' then _llist := '"'+SourceMenu.Items.Caption+'"' else _llist := _llist + ',"' + SourceMenu.Items.Caption+'"'; if _llist<>'' then begin JSInterface.JSCall('getStore().clearFilter', []); JSInterface.JSCode(#1'.getStore().filterBy(function (record){ if (['+ _llist +'].indexOf(record.get("text"))>-1) return false; else return true;});'); end else JSInterface.JSCall('getStore().clearFilter', []); end; Any workaround hints are appreciated greatly. Thank you, tonyM CC Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 24, 2019 Share Posted September 24, 2019 50 minutes ago, aem said: I want to be able to disable all the items a user doesn't have the right to access at startup. I will try to give you a solution... Quote Link to comment Share on other sites More sharing options...
aem Posted September 30, 2019 Author Share Posted September 30, 2019 I have kept trying various things to try to make unimenutree items display and act as disabled when disabled at runtime (the user's rights are applied) disable the unimenuitem - no effect // welcome1.enabled:=false; //top level // personalchecks1.enabled:=false; //child level disable unitreemenu items directly - no effect //unitreemenu1.items[0].enabled:=false; //does nothing //unitreemenu1.items[4].enabled:=false; //does nothing The alternative is to hide the tree items - but property alone has no effect // welcome1.visible:=false; //these do nothing // personalchecks1.visible:=false; But if these are followed by the code shown in the earlier post the top level tree item does disappear - the child level item does not. ---- So.... Although we would prefer to be able to truly show a disabled look to unimenutree items I may have stumbled upon a workaround to make items invisible. It seems that making the caption of the original unimenuitem empty does the job. // welcome1.caption := ''; //these make it invisible // personalchecks1.caption:=''; //child item invisible now too UniGUI is the greatest - and always getting better it seems tonyM Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.