d.bernaert Posted October 5, 2021 Share Posted October 5, 2021 Hi, I would like to expand or collapse a unitreemenu at runtime. There is a procedure Fullexpand, but that gives an javascript error. Can a complete expand and collapse be done another way? Thx, Dominique Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 5, 2021 Share Posted October 5, 2021 21 minutes ago, d.bernaert said: Can a complete expand and collapse be done another way? Hi Dominique, Try this approach: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniTreeMenu1.JSInterface.JSCall('rootItem.getNode().expandChildren', [True]); //expand //UniTreeMenu1.JSInterface.JSCall('rootItem.getNode().collapseChildren', [True]); //collapse end; 1 Quote Link to comment Share on other sites More sharing options...
d.bernaert Posted October 5, 2021 Author Share Posted October 5, 2021 Okay, thx, will try. Quote Link to comment Share on other sites More sharing options...
rhazell Posted November 18, 2021 Share Posted November 18, 2021 I am getting the same javascript error.. any luck using this alternative approach? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 18, 2021 Share Posted November 18, 2021 3 minutes ago, rhazell said: I am getting the same javascript error.. any luck using this alternative approach? Hello, What error are you getting? What code are you using and where? Quote Link to comment Share on other sites More sharing options...
rhazell Posted November 18, 2021 Share Posted November 18, 2021 procedure TMainForm.UniTreeMenu1Loaded(Sender: TObject); begin UniTreeMenu1.FullExpand; end; Runtime error: ExpandAll is not a function D11 & 1.90.0.1555 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted November 18, 2021 Share Posted November 18, 2021 4 minutes ago, rhazell said: procedure TMainForm.UniTreeMenu1Loaded(Sender: TObject); begin UniTreeMenu1.FullExpand; end; Runtime error: ExpandAll is not a function D11 & 1.90.0.1555 Quote Link to comment Share on other sites More sharing options...
mikromundo Posted September 25, 2023 Share Posted September 25, 2023 On 10/5/2021 at 6:46 AM, Sherzod said: Hi Dominique, Try this approach: procedure TMainForm.UniButton1Click(Sender: TObject); begin UniTreeMenu1.JSInterface.JSCall('rootItem.getNode().expandChildren', [True]); //expand //UniTreeMenu1.JSInterface.JSCall('rootItem.getNode().collapseChildren', [True]); //collapse end; I searched but couldn't find a post for my question. How should I proceed to: - enable/disable a specific menu item; - expand a specific menu item; I try with this code: for I := 0 to pTreeMenu.Items.Count - 1 do begin s1 := LowerCase( pTreeMenu.Items[I].Text); s2 := LowerCase( pSearch ); if pSearch = 'dashboards' then begin pTreeMenu.Items[I].Expanded := true; //pTreeMenu.Items[I].Expand( true ); end; end; Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 25, 2023 Share Posted September 25, 2023 3 hours ago, mikromundo said: I try with this code: for I := 0 to pTreeMenu.Items.Count - 1 do begin s1 := LowerCase( pTreeMenu.Items[I].Text); s2 := LowerCase( pSearch ); if pSearch = 'dashboards' then begin pTreeMenu.Items[I].Expanded := true; //pTreeMenu.Items[I].Expand( true ); end; end; Hello, Works for me. Check again, if the search word is correct !? Quote Link to comment Share on other sites More sharing options...
mikromundo Posted September 25, 2023 Share Posted September 25, 2023 I think I found the problem: pTreeMenu.SingleExpand := false; This property was TRUE. Setting FALSE worked. Thanks. Quote Link to comment Share on other sites More sharing options...
mikromundo Posted September 25, 2023 Share Posted September 25, 2023 @Sherzod I need to process this with "pTreeMenu.SingleExpand := true;" Any tip ? Quote Link to comment Share on other sites More sharing options...
mikromundo Posted September 25, 2023 Share Posted September 25, 2023 6 minutes ago, mikromundo said: @Sherzod I need to process this with "pTreeMenu.SingleExpand := true;" Any tip ? Forget this...all works! really need help !!! Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 25, 2023 Share Posted September 25, 2023 I will try to check. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 25, 2023 Share Posted September 25, 2023 1 hour ago, mikromundo said: really need help !!! Looks like there was some confusion in your code... Try this: procedure TMainForm.UniButton4Click(Sender: TObject); var I: Integer; s1, s2, psearch: string; begin psearch := 'dashboard'; s2 := LowerCase( pSearch ); for I := 0 to UniTreeMenu1.Items.Count - 1 do begin s1 := LowerCase( UniTreeMenu1.Items[I].Text); //if pSearch = 'dashboard' then if s1 = s2 then begin UniTreeMenu1.Items[I].Expanded := False; UniTreeMenu1.Items[I].Expanded := True; UniTreeMenu1.Items[I].Selected := True; end; end; end; Quote Link to comment Share on other sites More sharing options...
mikromundo Posted September 26, 2023 Share Posted September 26, 2023 Thanks.. I made a work around to work with pTreeMenu.SingleExpand True. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted September 27, 2023 Share Posted September 27, 2023 7 hours ago, mikromundo said: I made a work around to work with pTreeMenu.SingleExpand True. I didn't understand your case then, the above solution doesn't work for you? Works for me. 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.