【PB】子資料窗的應用

來源:互聯網
上載者:User

Getchild函數主要被用來得到一個資料視窗的子資料視窗該函數在兩種情況下可以使用,

1、取出資料視窗對象的下拉式資料視窗;                           

 2、取出複合風格(composite)資料視窗對象裡所嵌入的子資料視窗對象。

文法:integer dwcontrol.GetChild (string name, REF DataWindowChild     dwchildvariable )

例子1  這段程式取出一個composite資料視窗對象的兩個子資料視窗,並對他們進行過濾,和排序的操作。

/*dw_dy是串連一個composite資料視窗對象的一個資料視窗控制項。dw_1、dw_2分別是嵌套的資料視窗的NAME*/

String ls_filter

DataWindowChild dwc_czrw,dwc_czx//定義子資料視窗變數

dw_dy.Settransobject(sqlca)

dw_dy.Retrieve()

dw_dy.GetChild("dw_2",dwc_czrw)

dw_dy.Getchild("dw_1",dwc_czx)

ls_filter = "czrw_bh = '"+dw_3.GetItemString(dw_3.GetRow(),"czrw_bh")+"'"//過濾條件

dwc_czrw.SetFilter(ls_filter)

dwc_czrw.Filter()

ls_filter = "czx_rwbh = '"+dw_3.GetItemString(dw_3.GetRow(),"czrw_bh")+"'"

dwc_czx.SetSort("czx_sx A")

dwc_czx.Sort()

dwc_czx.SetFilter(ls_filter)

dwc_czx.filter()當然也可以通過資料共用(ShareData)等方式操作子資料視窗中的資料。訪問複合資料視窗對象.方法 :dw_dy.object.dw_1.object.對象

例子2   下拉資料視窗動態過濾 

在資料視窗dw_1的ItemFocusChanged事件中寫入如下指令碼:

Integer rtncode

String ls_nowFld,ls_deptid,ls_sql

DataWindowChild fld_child

rtncode = dw_1.GetChild("Unit_id",fld_child) //獲得Unit_id欄位名下拉資料視窗的控制代碼

If rtncode = -1 Then MessageBox("錯誤!", "不是下拉資料視窗!")

fld_child.SetTransObject(SQLCA) //設定事務對象

ls_sql = Lower(fld_child.GetSQLSelect())// 獲得DDDW的SQL語句

// 去除Sql 語句中的Where條件子句, 如原Sql 語句中須有Where條件子句,此處則需進行較

//複雜的處理,應視具體情況而定。

if Pos(ls_sql, " where ")>0 then ls_sql = Left(ls_sql,Pos(ls_sql, " where "))

//重新設定Sql 語句中的Where條件子句

ls_deptid=dw_1.Object.dept_id[GetRow()] //取得當前dept_id選定值

ls_sql = ls_sql + " Where dept_id = '" +Trim(ls_deptid)+"'"

//重新設定Sql 語句

fld_child.SetSQLSelect(ls_sql)

fld_child.Retrieve()//取得滿足條件的資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.