$PBExportHeader$pwd_ds_treeview.sru $PBExportComments$Class to generate a static treeview (using the non-HTML Datawindow and JS Script Class) forward global type pwd_ds_treeview from n_ds_cgibase end type end forward global type pwd_ds_treeview from n_ds_cgibase string dataobject = "pwd_d_treeview" end type global pwd_ds_treeview pwd_ds_treeview type variables string is_htmltext end variables forward prototypes public function string of_invokemethod (string as_method) private subroutine of_walktreeviewjs () protected function string of_gettreeview () end prototypes public function string of_invokemethod (string as_method);Choose Case as_method Case "of_gettreeview" ; If Len(session.of_getusername( ) ) > 0 Then Return of_gettreeview () Else httpheader.of_setredirect( webpath + "redirect_login_from_frameset.html") Return "" End If Case Else Return Super::of_invokemethod ( as_method ) End Choose end function private subroutine of_walktreeviewjs (); // Build Item and Search children.. // Possible performance improvements if the recursion is replaced by an iteration long ll_row long ll_rowcount string ls_itemtext long sales_id , cust_id , order_id , line_id long prev_sales_id , prev_cust_id , prev_order_id string ls_html string ls_id string ls_picturename ll_rowcount = This.RowCount() // Insert the Root... is_htmltext +=& 'TVROOT=new TreeViewItem("PB Web Easy - Tree View",RESOURCEBASE+"pb105icon.gif","","")~n' prev_sales_id = -1 prev_cust_id = -1 prev_order_id = -1 for ll_row = 1 to ll_rowcount sales_id = this.GetItemNumber(ll_row , 'employee_emp_id') cust_id = this.GetItemNumber(ll_row , 'cust_id') order_id = this.GetItemNumber(ll_row , 'id') line_id = this.GetItemNumber(ll_row , 'sales_order_items_line_id') if sales_id <> prev_sales_id and sales_id > 0 Then ls_itemtext = This.GetItemString ( ll_row , 'employee_emp_fname' ) + " " + This.GetItemString ( ll_row , 'employee_emp_lname' ) prev_sales_id = sales_id ls_id = String(sales_id) ls_html +=& 'TVS' + ls_id +'=TVROOT.insertItemLast ( new TreeViewItem("'+ls_itemtext+'",RESOURCEBASE+"sales.gif","sales","../pwd_ds_sales/of_detaildata?id='+ ls_id +'"));~n' end if if cust_id <> prev_cust_id and cust_id > 0 Then ls_itemtext = This.GetItemString ( ll_row , 'company_name' ) prev_cust_id = cust_id ls_id = String(cust_id) ls_html +=& 'TVC' + ls_id +'=TVS'+String ( sales_id )+'.insertItemLast(new TreeViewItem("'+ls_itemtext+ '",RESOURCEBASE+"customer.gif","customer","../pwd_ds_customer/of_detaildata?id='+ ls_id +'"))~n' end if if order_id <> prev_order_id and order_id > 0 Then ls_itemtext = "Order ID " + String ( order_id ) prev_order_id = order_id ls_id = String(order_id) ls_html +=& 'TVO' + ls_id +'=TVC'+String ( cust_id )+'.insertItemLast(new TreeViewItem("'+ls_itemtext+ '",RESOURCEBASE+"order.gif","order","../pwd_ds_order/of_detaildata?id='+ ls_id +'"));~n' end if if line_id > 0 then ls_itemtext = This.GetItemString ( ll_row , 'product_name' ) ls_picturename = GetItemstring ( ll_row, "product_picture_name" ) ls_picturename = "prd/"+ Left ( ls_picturename , Len ( ls_picturename ) - 3 ) + "gif" ls_id = String ( line_id ) ls_html +=& 'TVL' + String(order_id) +'_'+ ls_id +'=TVO'+String ( order_id )+'.insertItemLast(new TreeViewItem("'+ls_itemtext+ '",RESOURCEBASE+"'+ls_picturename+'","orderline","../pwd_ds_orderline/of_detaildata?order_id='+String(order_id)+'&line_id='+ ls_id +'"))~n' End if // Faster "String" Concatenation (but still poor...) if Len ( ls_html ) >8190 Then is_htmltext +=ls_html ls_html = "" End if next If Len ( ls_html ) > 0 Then is_htmltext += ls_html end subroutine protected function string of_gettreeview ();string ls_html This.SetTransObject(SQLCA) log.of_addmessage ( 1, "Retrieving" + " " + String (cpu()) ) If This.Retrieve ( ) < 1 Then Return "<BR>No rows found!" log.of_addmessage ( 1, "Retrieved " + String ( This.RowCount() ) + " " + String (cpu()) ) ls_html = & '<html><head><title>TreeView Sales</title>~n& <style>~n& body { background-color: white;}~n& td{ font-size: 8pt; font-family: verdana,helvetica; text-decoration: none; white-space:nowrap;} ~n& a { text-decoration: none; color:black}~n& </style>~n& <script src="'+JSRESOURCEPATH+'pwedwtree.js"></script>~n& <script>~n& RESOURCEBASE = "'+WEBPATH+'pic/tv16/"; ~n' // Walk from Root This.of_walktreeviewjs ( ) ls_html += is_htmltext + & '</script></head>& <body topmargin="5" leftmargin="5" marginheight="0">& <div style="position:absolute; top:0; left:0;height:0;"><table border=0 height=0>& <tr><td><font size=1pt>& <a style="font-size:7pt;text-decoration:none;color:blue" href="" target=detail></a>& </font></td></tr></table></div>& <script>buildTreeView()</script>& <noscript>A tree for site navigation will open here if you enable JavaScript in your browser.</noscript>& </body></html>' Return ls_html end function on pwd_ds_treeview.create call super::create end on on pwd_ds_treeview.destroy call super::destroy end on
- Sources
- pb9webeasy
- PBL
- pwd_ds_treeview.sru
File: pwd_ds_treeview.sru
Size: 5298
Date: Sat, 08 Dec 2007 15:38:35 +0100
Size: 5298
Date: Sat, 08 Dec 2007 15:38:35 +0100
- n_ds_cgibase pwd_ds_treeview(sru)