Jul 6, 2012

Powerbuilder - Extract Menu To Datawindow

1. Create Window, Datawindow and controls




2. Create A sample menu



3. Create window function

 public function boolean of_extract (menu am_menu, integer ai_from, integer ai_level, string as_parent);string     ls_text, ls_code  
 integer li_loop, li_count  
 Long ll_row  
 li_count = UpperBound(am_menu.Item[])  
 for li_loop = ai_from to li_count  
      ls_code = as_parent + string(li_loop,"00")  
      ls_text = am_menu.item[li_loop].Text  
      ll_row = dw_menu.InsertRow(0)  
      dw_menu.SetItem(ll_row,"menu_id", ls_code)  
      dw_menu.SetItem(ll_row,"label_menu", ls_text)  
      dw_menu.SetItem(ll_row,"level_id", ai_level)  
      dw_menu.SetItem(ll_row,"parent_id", as_parent)  
      of_extract(am_menu.Item[li_loop],1, ai_level + 1, ls_code)  
 next  
 return true  
 end function  


4. cb_extract Event Clicked()

 menu lm_main  
 if ddlb_1.text = 'm_main' then  
  lm_main = create m_main  
 else  
  lm_main = create m_sample  
 end if  
 dw_menu.reset()  
 of_extract(lm_main,1,0,'')   
 destroy lm_main  


5.See them in action



6. Cheers..



DOWNLOAD source code from 4Shared

2 comments: