uniguisyriusz Posted February 22, 2019 Share Posted February 22, 2019 Uni gui version 1.70.0.1485 In my app I have two types of users. For one of them I want to hide couple of menuitems or set Tunitreemenu other source menu depending on user type, how to do this in runtime? I found this solution , but it causes errors like hiding frames that must be visible! with mainMenu do begin SourceMenu.Items[0].Visible := False; _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; Link to comment Share on other sites More sharing options...
Sherzod Posted February 22, 2019 Share Posted February 22, 2019 3 hours ago, uniguisyriusz said: I found this solution , but it causes errors like hiding frames that must be visible! Hello, Please check again, you have the wrong code Link to comment Share on other sites More sharing options...
uniguisyriusz Posted February 22, 2019 Author Share Posted February 22, 2019 As an approximate solution for now - notching has changed since May 29, 2018? Link to comment Share on other sites More sharing options...
Sherzod Posted February 23, 2019 Share Posted February 23, 2019 20 hours ago, uniguisyriusz said: As an approximate solution for now - notching has changed since May 29, 2018? Yes, because it is a lightweight component to display data in a simple tree structure using a "Ext.data.TreeStore" Link to comment Share on other sites More sharing options...
FXSystems Posted March 23, 2022 Share Posted March 23, 2022 Hi everyone. I struggled with this problem for a long time and probably the solution is not elegant, but it works fine to rebuild the whole treeView. You can hide / show menu items or rename them. procedure TMainForm.BuildHamburgerMenu; var i: Integer; newItem : TUniTreeNode; procedure BuildSubordinateElements(NadrzedneMenu: TUniTreeNode; whichMenu : TUniMenuItem); Var ip: Integer; Begin for ip := 0 to whichMenu.Count - 1 do Begin if whichMenu.Items[ip].Visible then Begin newItem := treeMenu.Items.Add(NadrzedneMenu,whichMenu.Items[ip].Caption); newItem.ImageIndex:= whichMenu.Items[ip].ImageIndex; newItem.OnClick := whichMenu.Items[ip].OnClick; if (whichMenu.Items[ip].Count > 0) then BuildSubordinateElements(newItem,whichMenu.Items[ip]); End; End; end; Begin treeMenu.Items.Clear; if HamburgerMenuItems.Items.Count > 0 then Begin for i := 0 to HamburgerMenuItems.Items.Count - 1 do Begin if HamburgerMenuItems.Items[i].Visible then Begin newItem := treeMenu.Items.Add(nil,HamburgerMenuItems.Items[i].Caption); newItem.ImageIndex := HamburgerMenuItems.Items[i].ImageIndex; newItem.OnClick := HamburgerMenuItems.Items[i].OnClick; if (HamburgerMenuItems.Items[i].Count > 0) then BuildSubordinateElements(newItem,HamburgerMenuItems.Items[i]); End; End; End; End; Maybe someone will come in handy. 1 1 Link to comment Share on other sites More sharing options...
awendisch Posted August 8, 2022 Share Posted August 8, 2022 On 3/23/2022 at 10:44 AM, FXSystems said: Hi everyone. I struggled with this problem for a long time and probably the solution is not elegant, but it works fine to rebuild the whole treeView. You can hide / show menu items or rename them. procedure TMainForm.BuildHamburgerMenu; var i: Integer; newItem : TUniTreeNode; procedure BuildSubordinateElements(NadrzedneMenu: TUniTreeNode; whichMenu : TUniMenuItem); Var ip: Integer; Begin for ip := 0 to whichMenu.Count - 1 do Begin if whichMenu.Items[ip].Visible then Begin newItem := treeMenu.Items.Add(NadrzedneMenu,whichMenu.Items[ip].Caption); newItem.ImageIndex:= whichMenu.Items[ip].ImageIndex; newItem.OnClick := whichMenu.Items[ip].OnClick; if (whichMenu.Items[ip].Count > 0) then BuildSubordinateElements(newItem,whichMenu.Items[ip]); End; End; end; Begin treeMenu.Items.Clear; if HamburgerMenuItems.Items.Count > 0 then Begin for i := 0 to HamburgerMenuItems.Items.Count - 1 do Begin if HamburgerMenuItems.Items[i].Visible then Begin newItem := treeMenu.Items.Add(nil,HamburgerMenuItems.Items[i].Caption); newItem.ImageIndex := HamburgerMenuItems.Items[i].ImageIndex; newItem.OnClick := HamburgerMenuItems.Items[i].OnClick; if (HamburgerMenuItems.Items[i].Count > 0) then BuildSubordinateElements(newItem,HamburgerMenuItems.Items[i]); End; End; End; End; Maybe someone will come in handy. Work! Tanks! Link to comment Share on other sites More sharing options...
warobert Posted December 20, 2022 Share Posted December 20, 2022 Thanks! Very Good. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now