The Getchild function is mainly used to obtain the child data window of a data window. This function can be used in two cases,
1. Retrieve the drop-down data window of the data window object;
2. Retrieve the child data window objects embedded in the composite data window objects.
Syntax: integer dwcontrol. GetChild (string name, REF DataWindowChild dwchildvariable)
Example 1: This program extracts two child data windows of a composite data window object and filters and sorts them.
/* Dw_dy is a data window control that connects to a composite data window object. Dw_1 and dw_2 are the names of nested data windows */
String ls_filter
DataWindowChild dwc_czrw, dwc_czx // defines the child data window variable
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") + "'" // filter Condition
Dwc_czr1_setfilter (ls_filter)
Dwc_czr1_filter ()
Ls_filter = "czx_rwbh = '" + dw_3.GetItemString (dw_3.GetRow (), "czrw_bh") + "'"
Dwc_czx.SetSort ("czx_sx ")
Dwc_czx.Sort ()
Dwc_czx.SetFilter (ls_filter)
Of course, dwc_czx.filter () can also operate data in the subdata window through data sharing. Access the composite data window object. Method: dw_dy.object.dw_1.object. Object
Example 2 Dynamic Filtering in the drop-down data window
Write the following script in the ItemFocusChanged event of the data window dw_1:
Integer rtncode
String ls_nowd, ls_deptid, ls_ SQL
DataWindowChild fld_child
Rtncode = dw_1.GetChild ("Unit_id", fld_child) // obtain the handle of the Unit_id field name drop-down data window
If rtncode =-1 Then MessageBox ("error! "," Not the drop-down data window! ")
Fld_child.SetTransObject (SQLCA) // sets the transaction object
Ls_ SQL = Lower (fld_child.GetSQLSelect () // obtain the SQL statement of DDDW
// Remove the Where clause from the SQL statement. If the original SQL statement must have a Where clause, compare
// Complex processing depends on the actual situation.
If Pos (ls_ SQL, "where")> 0 then ls_ SQL = Left (ls_ SQL, Pos (ls_ SQL, "where "))
// Reset the Where clause in the SQL statement
Ls_deptid = dw_1.Object.dept_id [GetRow ()] // obtain the selected value of the current dept_id
Ls_ SQL = ls_ SQL + "Where dept_id = '" + Trim (ls_deptid) + "'"
// Reset the SQL statement
Fld_child.SetSQLSelect (ls_ SQL)
Fld_child.Retrieve () // obtain data that meets the conditions