可以通过POWERSCRIPT中的SHAREDATA函数在主从数据窗口见共享数据。在这种情况下,请不要添加数据。为使用N_CST_DWSRV_LINKAGE对象实现用主窗口中某列作为从数据窗口的检索参数,需执行以下步骤:
1。激活与主数据窗口的连接服务;
DW_MASTER.OF_SETLINKAGE(TRUE)
2。激活与从数据窗口的联接服务;
DW_DETAIL.OF_SETLINKAGE(TRUE)
3。在从数据窗口中实现与主数据窗口的连接;
dw_detail.inv_linkage.of_setmaster(dw_master)
4。注册相关列;
dw_detail.inv_linkage.of_register("emp_id","emjp_id")
5。指定当主数据窗口的记录焦点改变时,从数据窗口的操作(本例为检索新的记录);
dw_detail.inv_linkage.of_setstyle(dw_detail.inv_linkage.retrieve)
6。调用连接服务中的OF_SETTRANSOBJECT函数为所有在连接连中的数据窗口建立事物对象,该函数是数据窗口的最高级函数;
dw_master.inv_linkage.of_settransobject(sqlca)
7。对数据窗口的PFC_RETRIEVE事件增加检索逻辑(对与检索风格,用户只需对主数据窗口的PFC_RETRIEVE事件编写代码);
return this.retrieve()
8。调用主窗口的OF_RETRIEVE函数;
if dw_master.of_retieve()=-1 then
messagebox("错误",“retrieval error”)
else
dw_master.setfocus()
end if
8。按要求调用其他连接服务函数
=======================
//Enable Linkage Services
dw_1.of_setlinkage(true)
dw_2.of_setlinkage(true)
// Link this dw to its master.
dw_2.inv_linkage.of_SetMaster(dw_1)
//Register the common columns
dw_2.inv_linkage.of_register(is_col_1,is_col_2)
// Set up visual confirmation of saves and deletes.
dw_1.inv_linkage.of_SetUpdateOnRowChange (True)
dw_1.inv_linkage.of_SetConfirmOnRowChange (True)
//Enable required column services
dw_1.of_SetReqColumn(TRUE)
dw_2.of_SetReqColumn(TRUE)
//Option of of_setusecollinks
dw_2.inv_linkage.of_setusecollinks(li_collinks_option)
//dw_2.inv_linkage.of_setusecollinks(2) //1=FILTER,2=RETRIEVE,3=SCROLLTOROW
//Set the manner of the update chain to bottom-up FOR DETAIL
//dw_1.inv_linkage.of_setUpdateBottomUp(FALSE)
dw_1.inv_linkage.of_SetUpdateStyle (dw_1.inv_linkage.TOPDOWN)
dw_2.inv_linkage.of_SetUpdateStyle (dw_2.inv_linkage.TOPDOWN)
//Confirm deletes
dw_1.inv_linkage.of_SetConfirmOnDelete (True)
dw_2.inv_linkage.of_SetConfirmOnDelete (True)
//Set the style of the cascaded deletes from the master datawindow
dw_1.inv_linkage.of_SetDeleteStyle(1) //DELETE_ROWS from the database
// Set up visual confirmation of saves and deletes.
// This will be the initial setting for the example.
dw_2.inv_linkage.of_SetUpdateOnRowChange (True)
dw_2.inv_linkage.of_SetConfirmOnRowChange (True)
===================================================
this.of_setlinkage( true)
dw_1.of_setlinkage( true)
this.inv_linkage.of_linkto( dw_1)
this.inv_linkage.of_setstyle( this.inv_linkage.retrieve )
//this.inv_linkage.of_setarguments( /*string as_masterarg*/, /*string as_detailarg */)
//参数条件,顺序必须与SQL语句中定义的顺序一致
this.inv_linkage.of_setarguments('dict_type','dict_type')
this.inv_linkage.of_setarguments('status','有效')
dw_1.inv_linkage.of_settransobject(sqlca)
this.inv_linkage.of_SetUpdateOnRowChange(true)
this.inv_linkage.of_SetConfirmOnRowChange(true)