Wilton Ergon Posted May 26, 2018 Share Posted May 26, 2018 i try unimenuitem1.visible :=false; unimenuitem2.visible :=false; UniTreeMenu.SOURCEMENU :=mainMenuItems; UniTreeMenu.Refresh; UniTreeMenu.Repaint; unigui 1.10.0.1458 unsuccessfully. Quote Link to comment Share on other sites More sharing options...
albertovesx Posted May 27, 2018 Share Posted May 27, 2018 +1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted May 29, 2018 Share Posted May 29, 2018 Hi, As an approximate solution for now procedure TMainForm.UniButton1Click(Sender: TObject); var I: Integer; _llist: string; begin with UniTreeMenu1 do begin SourceMenu.Items[0].Visible := False; _llist := ''; for I := 0 to SourceMenu.Items.Count-1 do if not SourceMenu.Items[I].Visible then if _llist='' then _llist := '"'+SourceMenu.Items[I].Caption+'"' else _llist := _llist + ',"' + SourceMenu.Items[I].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; end; Best regards, Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted May 30, 2018 Author Share Posted May 30, 2018 you and js ninja Quote Link to comment Share on other sites More sharing options...
Gabriel Posted June 27, 2018 Share Posted June 27, 2018 Hi, As an approximate solution for now procedure TMainForm.UniButton1Click(Sender: TObject); var I: Integer; _llist: string; begin with UniTreeMenu1 do begin SourceMenu.Items[0].Visible := False; _llist := ''; for I := 0 to SourceMenu.Items.Count-1 do if not SourceMenu.Items[I].Visible then if _llist='' then _llist := '"'+SourceMenu.Items[I].Caption+'"' else _llist := _llist + ',"' + SourceMenu.Items[I].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; end; Best regards, Great. It only works when you are using TUniMenuItems as a SourceMenu? I'm creating the content of the menu at runtime and I can't make it work, Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 5, 2019 Share Posted March 5, 2019 27 minutes ago, CoderU said: How hide subitems? Sample Tablet Application has menu Dashboard -> Save Dashboard -> Export Dashboard -> Print I mean runtime How hide Save menu or how hide all function if all function hide then hide parent menu Dashboard Hello, Ok I will check Quote Link to comment Share on other sites More sharing options...
Sherzod Posted March 5, 2019 Share Posted March 5, 2019 And sorry, which edition and build of UniGUI are you using ?! Quote Link to comment Share on other sites More sharing options...
Kattes Posted January 31, 2020 Share Posted January 31, 2020 Sorry but I also have problems using your solutions. I have the following uniTreeMenu structure: .. and want to hide menu items "Management" and its children for "simple" users. Therefor I am using the following code: procedure TuDashboardFrame.UniPanelLoginClick(Sender: TObject); var s : string; i : integer; begin with MainForm do begin for i := 0 to UniTreeMenu1.Items.Count-1 do begin s := UniTreeMenu1.Items[i].AttachedMenuItem.Caption; if pos(s, 'Database Management Customers')>0 then UniTreeMenu1.Items[i].AttachedMenuItem.Visible := false; end; UpdateTreeMenu(UniTreeMenu1); end; end; in combination with your slightly adapted solution: procedure UpdateTreeMenu (myMenu : TUniTreeMenu); var I: Integer; _llist: string; begin with myMenu do begin SourceMenu.Items[0].Visible := False; _llist := ''; for I := 0 to SourceMenu.Items.Count-1 do if not SourceMenu.Items[I].Visible then if _llist='' then _llist := '"'+SourceMenu.Items[I].Caption+'"' else _llist := _llist + ',"' + SourceMenu.Items[I].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; end; Unfortunately this is not working Quote Link to comment Share on other sites More sharing options...
Kattes Posted February 1, 2020 Share Posted February 1, 2020 Thank you Sherzod! I slightly modified the solution you sent me, which I also want to share with the community. procedure HideMenueItems(var MyTreeMenu: TUniTreeMenu; const sHide: string); var s,sH : string; i : integer; llist: string; begin llist := ''; sH := ','+sHide+','; for i := 0 to MyTreeMenu.Items.Count-1 do begin s := ','+MyTreeMenu.Items[i].AttachedMenuItem.Caption+','; if pos(s, sH)>0 then begin MyTreeMenu.Items[i].AttachedMenuItem.Visible := false; if llist='' then llist := '"'+MyTreeMenu.Items[I].AttachedMenuItem.Caption+'"' else llist := llist + ',"' + MyTreeMenu.Items[I].AttachedMenuItem.Caption+'"'; end; end; if llist<>'' then begin MyTreeMenu.JSInterface.JSAssign('_rtext', [MyTreeMenu.JSControl.JSArray(llist)]); MyTreeMenu.JSInterface.JSCode('var me='#1';'+ 'if(me._rtext) me.getStore().each(function(record) {'+ ' if (me._rtext.indexOf(record.get("text")) > -1) {'+ ' record.remove()'+ ' }'+ '});' ); end; end; procedure TMainForm.UniButtonHideClick(Sender: TObject); begin HideMenueItems(UniTreeMenu, 'Dashboard,Database,Management,Customers'); end; 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 1, 2020 Share Posted February 1, 2020 Thank you for sharing! Quote Link to comment Share on other sites More sharing options...
Wilton Ergon Posted August 10, 2020 Author Share Posted August 10, 2020 On 2/1/2020 at 3:34 PM, Kattes said: Thank you Sherzod! I slightly modified the solution you sent me, which I also want to share with the community. procedure HideMenueItems(var MyTreeMenu: TUniTreeMenu; const sHide: string); var s,sH : string; i : integer; llist: string; begin llist := ''; sH := ','+sHide+','; for i := 0 to MyTreeMenu.Items.Count-1 do begin s := ','+MyTreeMenu.Items[i].AttachedMenuItem.Caption+','; if pos(s, sH)>0 then begin MyTreeMenu.Items[i].AttachedMenuItem.Visible := false; if llist='' then llist := '"'+MyTreeMenu.Items[I].AttachedMenuItem.Caption+'"' else llist := llist + ',"' + MyTreeMenu.Items[I].AttachedMenuItem.Caption+'"'; end; end; if llist<>'' then begin MyTreeMenu.JSInterface.JSAssign('_rtext', [MyTreeMenu.JSControl.JSArray(llist)]); MyTreeMenu.JSInterface.JSCode('var me='#1';'+ 'if(me._rtext) me.getStore().each(function(record) {'+ ' if (me._rtext.indexOf(record.get("text")) > -1) {'+ ' record.remove()'+ ' }'+ '});' ); end; end; procedure TMainForm.UniButtonHideClick(Sender: TObject); begin HideMenueItems(UniTreeMenu, 'Dashboard,Database,Management,Customers'); end; your example works perfectly, but it only removes the menu items, as I do to reassemble them and return the ones that were removed. if (me._rtext.indexOf(record.get("text")) > -1) {'+ ' record.remove()'+ ???? the example of friend Sherzod, applied only one filter to the menu items, this one does and removes the item, I need to recompose the items to return to the original state. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted August 11, 2020 Share Posted August 11, 2020 Hello, Are you using the latest UniGUI builds? Quote Link to comment Share on other sites More sharing options...
emin Posted January 17, 2021 Share Posted January 17, 2021 I've used above script and it has worked. However a memory leak occurred. I have no idea how I fix the leak. I checked the script, it seemed Ok. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 18, 2021 Share Posted January 18, 2021 22 hours ago, emin said: I've used above script and it has worked. However a memory leak occurred. I have no idea how I fix the leak. I checked the script, it seemed Ok. Hello, Can you make a simple testcase to check? Quote Link to comment Share on other sites More sharing options...
emin Posted January 18, 2021 Share Posted January 18, 2021 I added a test caseunitreemenutest.rar unitreemenutest.rar Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 18, 2021 Share Posted January 18, 2021 10 minutes ago, emin said: I added a test caseunitreemenutest.rar Try this approach for now: ... if llist<>'' then begin //MyTreeMenu.JSInterface.JSAssign('_rtext', [MyTreeMenu.JSControl.JSArray(llist)]); MyTreeMenu.JSInterface.JSAssign('_rtext', [MyTreeMenu.JSInterface.JSStatement('[' + llist + ']')]); MyTreeMenu.JSInterface.JSCode('var me='#1';'+ 'if(me._rtext) me.getStore().each(function(record) {'+ ' if (me._rtext.indexOf(record.get("text")) > -1) {'+ ' record.remove()'+ ' }'+ '});' ); end; ... Quote Link to comment Share on other sites More sharing options...
emin Posted January 18, 2021 Share Posted January 18, 2021 Hello Sherzod Memory leak warning disappeared when I used new script. Thanks your help, above and beyond your sincere help I think we need a documentation source to handle that kind of problem. To be honest it doesn't make sense for me why the memory leak has accured and why it's disappeared after replacing the script. I always try to understand logic instead of copy-paste script. But this time I couldn't Many thanks again 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 18, 2021 Share Posted January 18, 2021 We will check. Quote Link to comment Share on other sites More sharing options...
picyka Posted June 17, 2021 Share Posted June 17, 2021 I went back to addressing this item on my system, I still didn't have a solution, I was searching I found a code would it be possible to set no nodes visible? if not AMenu.Items[I].Visible then begin var lJs := #1'.getStore().getNodeById("' + AMenu.Items[I].Id.ToString + '");'; AMenu.JSInterface.JSCode(lJs); end; Quote Link to comment Share on other sites More sharing options...
andyhill Posted June 19, 2021 Share Posted June 19, 2021 Sherzod, following on from above, how can we ADD Primary Items and ADD Child Items (not remove) ? Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted June 19, 2021 Share Posted June 19, 2021 Yes, it can be cleared before creation, and then hidden or displayed after creation 1624084827640.mp4 1 Quote Link to comment Share on other sites More sharing options...
picyka Posted June 19, 2021 Share Posted June 19, 2021 10 horas atrás, Andyhill disse: Sherzod, seguindo de cima, como podemos adicionar itens primários e adicionar itens infantis (não remover) ? I would like the same functionality we have in the demo http://prime.fmsoft.net/demo/desktop/mdemo.dll when searching the menu name Quote Link to comment Share on other sites More sharing options...
andyhill Posted June 19, 2021 Share Posted June 19, 2021 "Yes, it can be cleared before creation, and then hidden or displayed after creation" I actually want a total new set of Menu Items (added at runtime when needed for each criteria), not a bloated Items List that we try to hide unwanted Items. Sherzod, how can we ADD MenuTree Primary Items and ADD associated Child Items (not remove) at runtime ? 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.