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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show all data from a table in datawindow using DDDW custom ALL selection

Status
Not open for further replies.

dc03kks

Programmer
Nov 12, 2015
3
GR
Hi guys,

i have created in powerbuilder a dropdown data window to function as a filter to get values from a table named product and then by selecting smthng from the dropdown list in another datawindow to show all the retrieved data associated with the selection from the dropdown list.

Its working fine, the code in my w_firstwindow in open() is like that

datawindowchild child_data
dw_prod_filter.insertrow(0)
if dw_prod_filter.getchild( 'productname', child_data ) = 1 then
child_data.settransobject( SQLCA )
child_data.retrieve( )
child_data.insertrow(1)
child_data.setitem( 1, 'name', 'ALL' )
child_data.setitem( 1, 'picture_name', 'ALL' )
child_data.selectrow( 0, false )
end if

in the datawindow filter dw_prod_filter in the itemchanged() i have this

string ls_product

ls_product = dw_prod_filter.GetItemString(row,'productname')

dw_product_list.retrieve( data )

and in the dw_product_list in the constructor() i have this

this.setTransObject( SQLCA )

i have made and the necessary retrieval arguments through power builder and is working fine.

BUT,

i want when i select the ALL option from the dropdown list to retrieve the whole table product, i have tried many things with no luck,, and i was wondering if anyone can help me out, any help would be really appreciated,

Thank you in advance guys
 
Firstly, I would create an event do do the processing you currently have in the itemchanged event. The event should have the row number as a parameter. You can then POST a call to this event from itemchanged. This way the users entry (what is called 'data') is accepted into the datawindow and can be used in subsequent methods. You can use it in the new event via a 'getitemstring' call using the passed row number and the column name (you called it 'productname' in your example).

The issue you have is in sql you are sending the string 'ALL' as the retrieval argument. You will have to have logic in the sql making up the datawindow to account for the value 'ALL'. Example: of the sql is

SELECT name, id FROM product WHERE name = :name;

you need to change it to something like

SELECT name, id FROM product WHERE CASE :name = 'ALL' THEN 1 = 1 ELSE name = :name END;

SQL CASE statements can vary by dbms so you should look up the proper one for your situation.

Matt

"Nature forges everything on the anvil of time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top