• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2459
  • Last Modified:

Dropdown list - Datawindow

I am novice to Power Builder.  How can I dynamically additem to dropdown list from datawindow?
0
peterdevadoss
Asked:
peterdevadoss
  • 4
  • 2
  • 2
  • +3
1 Solution
 
NMiCommented:
Maybe you can use ddlb.AddItem ? ;)

Do you need to populate your listbox with items from a table ?
0
 
SylvainPouliotCommented:
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.
0
 
BhattiCommented:
Please follow the intructions from SylvianPouliot.
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
peterdevadossAuthor Commented:
Yes. I want to populate the listbox with items from a table.
0
 
NMiCommented:
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 ;
0
 
SylvainPouliotCommented:
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...
0
 
NMiCommented:
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 ?
0
 
BhattiCommented:
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
0
 
Caseys95Commented:
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.
0
 
NMiCommented:
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.
0
 
peterdevadossAuthor Commented:
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.
0
 
Caseys95Commented:
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().
0
 
moduloCommented:
PAQed with points refunded (20)

modulo
Community Support Moderator
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now