Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DropDown Datawindow Query

Status
Not open for further replies.

nagendertank

Programmer
Feb 20, 2013
5
0
0
Hi I am new in powerbuilder Technology.Currently I am working on an existing project and doing some enhancement.But I stuck at one place.

I have two datawindow Like DW_A and DW_B.

When I click on a button "Add Row"
It Adds row in DW_A

Ex. Column-A Column-B
ABC 123
CDE 456
EFG 678

DW_A is not save in database till now.Data is only in buffer.

Now I am Inserting new row in DW_B which have one dropdown.
This drop must have Column-A value("ABC","CDE","EFG").
I used Child datawindow concept but not able to populate.

Please help me that how can i populate dropdown with DW_A-Column-A values?
 
To use a dropdowndatawindow you first have to define the 'dropdown' datawindow object. Normally this only has a single display column (the 'human readable' value which shows in the dropdown).

Next you define the datawindow for your user entry form. The column on this form which will contain the dropdown normally has some 'non human readable' value (like a key value). In the edit property of the column you choose type 'Dropdowndatawindow' and choose the first datawindow object and then indicate the visible column and the data column. The visible column is what the user sees and the data column is what gets saved to the database.

When you insert a new row into the datawindow and want the dropdowndatawindow column to show a value you need to retrieve the data for that child datawindow by using a getchild, settransobject, and retrieve followed by a setitem of a value contained within the list of key values in that cropdowndatawindow. So if my dropdowndatawindow has the values (1 ONE, 2 TWO, 3 THREE --the numeric is the key and the word is the display value) I need to setitem a 1,2, or 3 in the new row so the corresponding word shows. If I setitem another value - say a 4 - the field will display 4 and not any word since that value (4) is not contained in the dropdowndatawindows buffer.

I hope this helps

Matt

"Nature forges everything on the anvil of time"
 
Hi

If you need to populate the dddw with data that's not yet in the database why don't use a dropdownlistbox instead? So you can populate it with the data from DW_A that is in buffer. Or save DW_A and then make a retrieve to the child datawindow.

Hope this helps.

Lucas.
 
Hi Thanks For Your Response.....

Now I am able to populate that dropdown but have another problem.

Actually DW_B have two dropdown. The first dropdown is populated with previous datawindow(DW_A) buffer which issue is solves. Now Dropdown-2 is populated based on first drop down data.

So I write some script on ItemChanged Event of DW_B.

For Ex :

If I selects "ABC" in DropDown-1 then DropDown-2 populated with Apple,Aeroplane if selects "CDE" populated with Boy,Baby.

Now I am inserting one row in DW_B and Selects ABC in dropdown-1 then DropDown-2 have Apple,Aeroplane. Now I am again inserting new row in DW_B and Selects "CDE" then current row Dropdown-2 populate with Boy,Baby but as well as previous row dropdown-2 also changed with Data Boy,Baby...

How Can I prevent this type of change in Dropdown-2?????

Dropdown-2 have one child datawindow which selects data from some SQL Query with where data = dropdown-1 values. I retrieved this child datawindow at Item change in dropdown-1.
 
It sounds like your itemchanged script is setting values for all rows instead of the specific one whose value has changed.

Matt

"Nature forges everything on the anvil of time"
 
Yeah matt This is something like u said.....

Can u tell me that how can i set value only for specific row????

Please Help me....

Nagendra
 
The itemchanged event has a parameter called "row". This is the row number for the row containing the column which changed. Use that to set the value in the dddw field for the same row.

Matt

"Nature forges everything on the anvil of time"
 
Hi Matt

I am not able to understand how to set value for particular row.

The code snippet as follows on Itemchanged event of dw_B:

dw_B.getChild("lmt_typ_code",idwc_entm_limit)
dw_B.getChild("ppt_entm_id",idwc_entm_desc)
idwc_entm_limit.setTransobject(SQLCA)
idwc_entm_desc.setTransobject(SQLCA)
ls_col_name = dwo.name
ll_entm_cd = idwc_entm_desc.GetItemNumber(idwc_entm_desc.GetRow(), "entm_cd")

Choose Case ls_col_name
Case "ppt_entm_id"
il_ppt_entm_id = long(data)
idwc_entm_limit.retrieve(ll_entm_cd) // This is cause to change data of previous row also. How can I prevent that it not change data of previous row???

END CHOOSE

It changes child window data for previous row also....
 
First, remove the getchild stuff from the itemchanged event and put it in a event which gets triggered once the window is opened (thus setting the idwc_entm_limit reference). The way you are doing it, this gets triggered each time a change is made to the datawindow which is incorrect.

Next, it looks like you need to be using a Find to search for the value in idwc_entm_limit with a find string along the lines of 'entm_cd = ' + string(ll_entm_cd). Look in the help for using the Find method in a datawindow.

Matt

"Nature forges everything on the anvil of time"
 
Hi Matt

Thanks For replying. I will try this way tomorrow.
But I have doubt that I am retrieving Data from database in idwc_entm_limit with some query like Select limit_type from limit where lmt_typ_code = :ll_entm_cd so how can I search before retrieve and If i do retrieve then it also change data for previous row because previous row dropdown also refer to same childdatawindow....
Actually I am very poor in powerbuilder......


Nagendra
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top