A method of coordinating multi-data window data manipulation in PB (that is, multiple tab tags can be saved simultaneously)

Source: Internet
Author: User
Tags zip

1, the question of the proposed
A data window is an object in power builder that retrieves, behaves, and manipulates data. If a data table is not many columns, using a single data window to manipulate the data is easy to implement, but in the actual application, the number of columns in the data table is dozens of, even hundreds is not uncommon, then with a single data window scrolling is obviously inconvenient, a natural idea is to use the tab Control and tab page, A data window control is placed on each tab page, and each data window control is organized to manipulate the columns of the data table, but the attendant problem is how to coordinate the storage of data entered or modified in these data windows, and the call to publish an update () function for each data window is not OK. We have explored in the actual development, add a Background data window to do mediation, solve the problem of multi-data window manipulation data.

2, coordination of multi-data window data manipulation of a solution
The basic idea is: in the data manipulation of the data window control, in addition to a data window control, set it is not visible, and set its data window object for a selection of all columns in the Data Table Data window, the other data window control input or modified data in real-time transmission to come over, You can update the data for the control.
Without losing its generality, the following is illustrated by the example of data entry for the Customer table in the PowerBuilder database psdemodb.db.
The Customer table has "id", "fname", "lname", "Address", "City", "state", "zip", "phone", "Company" nine columns, where "id" is of type integer and the remainder is char type.
(1) Create Data window
Set up three data Windows D_1, D_2, d_3, Data window d_1 select "id", "fname", "lname" three columns, d_2 choose "Address", "City", "state" three columns, d_3 select "Zip", "" "" Phone "," Company _name "three columns. Then create the Data window D_4, and select all columns in the data table.
(2) Build tab Control and tab page
Create a tab control tab_1, create three tab pages Tabpage_1, tabpage_2, Tabpage_3.
(3) Building Data window controls
In (2) The three tab pages are placed in the Dw_1, Dw_2, dw_3 Three Data window controls, set their Data window objects are d_1, D_2, D_3.
Also, place a data window control dw_4 in the window without selecting its "visible" property.
(4) Writing code
In the Tab_1.tab_page_1.dw_1 editchanged event, write the following code:
The code starts with this
Set the variable, id_value the value of the ID column in the data table
int I_m,i_n,id_value
String Str_fname,str_lname
Fetch dw_1 Current number of rows
I_m=tab_1.tabpage_1.dw_1.getrow ()
Fetch Dw_4 Current number of rows
I_n=dw_4.getrow ()

Tab_1.tabpage_1.dw_1 and Dw_4 receive data floating on the Data window control surface
Tab_1.tabpage_1.dw_1.accepttext ()
Dw_4.accepttext ()

Take the value of the "id" column in dw_1 to the variable Id_value
Id_value=tab_1.tabpage_1.dw_1.getitemnumber (i_m, "id")
Assigns the value of the variable Id_value to the "id" column in Dw_4
Dw_4.setitem (i_n, "id", Id_value)

Take the value of the "fname" column in dw_1 to the variable str_fname
Str_fname=tab_1.tabpage_1.dw_1.getitemstring (I_m, "fname")
Assigns the value of the variable str_fname to the "fname" column in Dw_4
Dw_4.setitem (I_n, "fname", Str_fname)

Take the value of the "lname" column in dw_1 to the variable str_lname
Str_lname=tab_1.tabpage_1.dw_1.getitemstring (I_m, "lname")
Assigns the value of the variable str_lname to the "lname" column in Dw_4
Dw_4.setitem (I_n, "lname", Str_lname)
The code ends here.

The Editchanged event code of Tab1.tab_page_2.dw_2, Tab1.tab_page_3.dw_3, can be written against the Editchanged event code of TAB1.TAB_PAGE_1.DW_1, withheld.
Program in PB65 and PB7 debugging through, the program runs, regardless of the new data, or Dw_1, dw_2, dw_3 data column modification, data are transmitted to dw_4 in real-time, only to save or update dw_4, so as to solve the multi-data window data manipulation coordination problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.