Jump to content

uniTreeMenu - disable child items? hide child items?


aem

Recommended Posts

 

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

Link to comment
Share on other sites

 

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

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...