Link to home
Start Free TrialLog in
Avatar of peterdevadoss
peterdevadoss

asked on

Dropdown list - Datawindow

I am novice to Power Builder.  How can I dynamically additem to dropdown list from datawindow?
Avatar of NMi
NMi

Maybe you can use ddlb.AddItem ? ;)

Do you need to populate your listbox with items from a table ?
If you are using a dropdown list box in a Datawindow, you have to " re-create " your list:

dw_1.Modify("emp_status.Values='Active~tA/Part Time~tP/Terminated~tT'")

The syntax is:
Description~tDataValue/

So build up a string using the value you want and use modify.
Please follow the intructions from SylvianPouliot.
Avatar of peterdevadoss

ASKER

Yes. I want to populate the listbox with items from a table.
That's my sample script:



declare clients cursor for
  select CLIENT_TITLE from CLIENTS ;


string client_title

open clients ;

if sql_error("open clients") then
     rollback;
     return
end if


fetch_next:

fetch clients
 into :client_title ;

if sqlca.sqlcode = 100 then
     goto fetch_exit
end if

AddItem(client_title)

goto fetch_next

fetch_exit:

close clients ;
give me the name of your table / columns and datawindow columns
I'll show you...

NMI solution uses a cursor.  It's ok, but he is still using additem...  and this function is for a Listbox, it won't work in your case...
SylvainPouliot: He just said: "I want to populate the listbox with items from a table." - so why do you think that's not what he needs ? ;)

I know by my practice that this solution with cursor and ddlb is not very good in terms of scalability. I've got a table with 8k cells that I need to load into ddlb. If this table is loaded the normal way in dw, it takes just no time. If I load it info ddlb using cursor, the operation takes almost 5s. Maybe, you can suggest a better solution for such huge DDLBs ?
Hello  peterdevadoss,

There is difference between ListBox and Datawindow.

Datawindow and DropDownDataWindow are two datawindows. Please first deciede what exactly you want.

LISTBOX OR DROPDOWNDATAWINDOW OR DATAWINDOW.

It not realy clear what do you mean by listbox in datawindow, that mean in datawindow you choose a column and select it as dropdownlistbox.

If it is dropdownlistbox then follow the insruction of SylvainPouliot.

Let us know where you want to papulate data, in DropDownListBox or DropDownDataWindow.


THANKS


Best regards

Bhatti
Why can't you use a DDDW (DropDownDataWindow). There are techniques to selecting a subset of a table if this is what needs to be done. This always seems to be a more practical solution when populating from a database table. I would suggest using DDLB ( DropDownListBox ) for fixed lists where you can pre-define the list in the DW painter during development.

The DDDW is a child DW and can be manipulates just like a DW. Look in the PB help for references to DataWindowChild.
The DDDWs SQLSelect can be modified before retrieval, It can be Filtered. There is a lot that can be done to control the list prior to it's retrieval.
Caseys95: There's an opinion that DDDW looks just ugly ;)
Of course, I mean the case when this DDDW is the only control, not the part of some big datawindow.
I Just come to know from u guyz that there is a DROPDOWNDATAWINDOW object.  Actually thats the one i am looking for.  I am sorrr for confusing u guyz.
MNi,

Your right, I was not thinking of it being used that way. I was assuming the list is part of a DW. Not a control on a window. As a window control, I would probably use the DDLB as it is easily loaded using AddItem().
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial