0
Votes
Undo
  1. lingaiah T
  2. PowerBuilder
  3. Saturday, 15 October 2022 07:44 AM UTC

Dear Team,

I have a data in SQL Server Table with below format;

 

Create Table Menus( id int identity(1,1), menuID int , menuname varchar(50), ParentID int )


Insert into Menus(menuID,menuname,ParentID) values (1,'File',-1)
Insert into Menus(menuID,menuname,ParentID) values (2,'New',1)
Insert into Menus(menuID,menuname,ParentID) values (3,'Project',2)
Insert into Menus(menuID,menuname,ParentID) values (4,'File Query',2)
Insert into Menus(menuID,menuname,ParentID) values (5,'Close',1)
Insert into Menus(menuID,menuname,ParentID) values (6,'Edit',-1)
Insert into Menus(menuID,menuname,ParentID) values (7,'Cut',6)
Insert into Menus(menuID,menuname,ParentID) values (8,'Copy',6)
Insert into Menus(menuID,menuname,ParentID) values (9,'Paste',6)
Insert into Menus(menuID,menuname,ParentID) values (10,'Paste Special Values',9)
Insert into Menus(menuID,menuname,ParentID) values (11,'Paste Special Formulas',9)
Insert into Menus(menuID,menuname,ParentID) values (12,'Paste Special Formulas',11)

 

 

Create Table Menus_rights ( rid int ,menuid int,rights_code varchar(7),user_id varchar(8))
Insert into Menus_rights(rid,menuid,rights_code,user_id) values (1,2,'CMD','lingai')
Insert into Menus_rights(rid,menuid,rights_code,user_id) values (2,11,'P','lingai')

 


With Cte as
(
Select h1.menuid,h1.parentid,h1.menuname, menuname self_description, cast(id as varbinary(max)) [level],cast(h1.id as varchar(max)) [levelid]
from menus h1
where h1.ParentID <=0
Union all
Select h2.menuid,h2.parentid,c.self_description,h2.menuname,c.[level]+cast(h2.id as varbinary(max)) as [level],
c.[levelid] + '>' + cast (h2.id as varchar(10)) [levelid]
from menus h2
inner join cte c on h2.ParentID = c.menuid
)
Select * from
cte
cross apply (select parsename(REPLACE(REVERSE(levelid), '>', '.'), 1))c1(lvl1)
cross apply (select parsename(REPLACE(REVERSE(levelid), '>', '.'), 2))c2(lvl2)
cross apply (select parsename(REPLACE(REVERSE(levelid), '>', '.'), 3))c3(lvl3)
cross apply (select parsename(REPLACE(REVERSE(levelid), '>', '.'), 4))c4(lvl4)

/*
cross apply (select substring(levelid,1,charindex('>',levelid+'>')-1))c1 (rootlevelid1)
cross apply (select substring(levelid,1,charindex('>',levelid+'>')-1))c2 (rootlevelid2)
cross apply (select substring(levelid,1,charindex('>',levelid+'>')-1))c3 (rootlevelid3)
cross apply (select substring(levelid,1,charindex('>',levelid+'>')-1))c4 (rootlevelid4)
*/
Left join Menus_rights on Menus_rights.menuid = cte.menuID
order by [level] option (maxrecursion 1000)

I want Generate RIBONBAR from above Result set

-----------------------------------------

File                         

     New                

   

Edit

      paste

               paste special formulas      

-------------------------------------------------------------------------------------

 

 

Accepted Answer
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Saturday, 15 October 2022 14:28 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi Lingiah;

    Unfortunately, RB's & Menu's are not like objects and thus have not much DNA in common. It's basically the Apples & Oranges comparison.

Regards.... Chris 

Comment
There are no comments made yet.
Peter Pang @Appeon Accepted Answer Pending Moderation
  1. Monday, 17 October 2022 09:08 AM UTC
  2. PowerBuilder
  3. # 1

Hi Lingiah,

 

Thanks for reporting this problem.

According to your description, looks like you want to dynamically add a menu item to the Ribbonbar control. You can retrieve data from the database through Datastore and manually code menu items based on the data. But there’s a limitation, the menu can only have 2 levels. Using only the menu cannot reflect the advantages of Ribbonbar. For more usage scenarios, please refer to the Ribbonbar practice in the Example Graph App that comes with PB.

 

Here is the simple code to manually create the application menu (see attachment for details):

RibbonApplicationMenu               lr_appMenu
RibbonApplicationButtonItem   lr_appButton
Long      ll_Menu1, ll_Menu2, ll_Menu3

//DataStore

ll_Menu1 = lr_appMenu.InsertMasterItemFirst("New", "New!", "")
lr_appMenu.addMasterSeparatoritem()
ll_Menu2 = lr_appMenu.InsertMasterItemLast("Edit", "edit!", "")
lr_appMenu.addMasterSeparatoritem()
ll_Menu3 = lr_appMenu.InsertMasterItemLast("Close", "Close!", "")

lr_appMenu.InsertMasterItemFirst(ll_Menu1, "Project", "", "ue_Project")
lr_appMenu.InsertMasterItemLast(ll_Menu1, "File Query", "", "ue_FileQuery")

lr_appMenu.InsertMasterItemFirst(ll_Menu2, "Cut", "Cut!", "ue_Cut")
lr_appMenu.InsertMasterItemLast(ll_Menu2, "Copy", "Copy!", "ue_Copy")
lr_appMenu.InsertMasterItemLast(ll_Menu2, "Paste", "Paste!", "ue_Paste")

lr_appButton.text = "File"
lr_appButton.SetMenu(lr_appMenu)
rbb_1.SetApplicationButton(lr_appButton)

 

Best Regards,

Peter

 

Attachments (1)
Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.