dddw dropdown list with custom row!

Hi,
I have dddw control which is retrieving the row data dynamically from database table.
But I want to add a row called “All”. This does not exist in the database. How do I add this to the dropdown list?
NightManAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sys_ProgCommented:
Use GetChild () to get a reference to your dddw

Then use InsertRow() to insert a row in the child dddw

and then use SetItem () to set the value "All" in the corresponding columns

HTH

Amit
0
gajender_99Commented:
if your data base is oracle then
use this example

select 0 as id, 'ALL' as name from dual
union
SELECT id, name from table

this will allwas include the name 'ALL' with id 0
rest you can change youself
0
NightManAuthor Commented:
no, I am using SYBASE and MSSQL
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

gajender_99Commented:
you can you it as show below then


select 0 as id, 'ALL' as name
union
SELECT id, name from table
0
gajender_99Commented:
sorry for spealing
you can use it as show below then


select 0 as id, 'ALL' as name
union
SELECT id, name from table
0
NightManAuthor Commented:
yea, but I am showing only one colum in the dropdown list.

here is the sql
SELECT case_officer.code  
    FROM case_officer
0
gajender_99Commented:
select 'ALL' as code
union
select case_officer.code from case_officer

this should work
0
NightManAuthor Commented:
ok, now it is showing up as the first line. but disapear in the list if i make a dropdown selection.
0
gajender_99Commented:
is the officer code a numeric value or a string value
0
gajender_99Commented:
or in the sql use can use the order by clause
0
NightManAuthor Commented:
I got everything working but except the "ALL" which disapper when i make a selection. what i read is When the dropdown box is selected, then the selected value will be used in retrival argument for another datawindow. selection of "all" will serve as wildguard input for the retrival argument. and the "ALL" should stay in the dropdown list as well.
0
NightManAuthor Commented:
order by is not allowed by powerbuilder conflicting with union. and the value is string.
0
gajender_99Commented:
then what you have to change you sql code
if the code is a numeric field then use this
(
select 'ALL' as s_code, 0 as code
union
select string(code) as s_code, code  from case_officer)

or

select 'ALL' as s_code, 'ALL' as code
union
select code as s_code, code  from case_officer

and the go to the properties of the dddw
undet edit/display column select the s_code and under the data column select the code

and then in you script you can use the value to retrieve the data depending upon the selection
hope this works


0
NightManAuthor Commented:
not seems to be working, both are counted as code. there are no s_code in the properties
0
gajender_99Commented:
s_code is not in the properties but under the edit there is display column when you click there you should get two colums  s_code and Code you have to select s_code as display column and code as data column .

this will only appear only when you change the sql of you dddw window.

or if you like just send me you library to gajender_99 at hotmail.com  so that i can change and re send you
0
NightManAuthor Commented:
What I have there is 2 "code". no "s_code" available in the list.
0
NightManAuthor Commented:
yes, I already changed the SQL ofcourse.
0
gajender_99Commented:
i would check this and get back to you soon
0
gajender_99Commented:
can you send me you sql which you are using in dddw
0
NightManAuthor Commented:
I tried this as you suggested:

select 'ALL' as s_code, 'ALL' as code
union
select code as s_code, code from case_officer


the org. sql was

select caseofficer.code from case_officer
0
gajender_99Commented:
ok what i have found is the the ALL is on the top when you do a selection the selected code becomes the default one


a: have you checked  V ScrollBar under the edit properties. if not check the the v Scroll bar
 and now when u run you application you should be able to get the list.

b: open the dddw go to rows--> sort and select the code and click the ascending this will bring you list is ascending order every time you run it.

c: use the  previous sql which was

select 'ALL' as code
union
select case_officer.code from case_officer

and do the necessary  things in the data window
0
NightManAuthor Commented:
the v.scroll bar is alreay enabled. I can see all the list. my problem is if I use a sort, then the ALL is disapear from the list.
if I remove the sort, then it appear as a default, but still disapear, when I select any other item in the dropdown. then it is not existing in the dropdown box anymore. I guess the getchild and other thing may be the solution. but I do not know how to implement it.
0
gajender_99Commented:
ok here is the code

long ll_row
datawindowchild dwcClient

dw_client.GetChild ("Code ", dwcClient)
dwcClient.SetTransObject (SQLCA)
dwcClient.Retrieve ()
ll_row=dwcClient.insertrow(0)
dwcClient.Setitem("code",'ALL')

hope his might help you

0
gajender_99Commented:
dw_client is your datawindow
0
namasi_navaretnamCommented:
Use '*ALL' as your code instead of "ALL".
*ALL will appear as the first row even if you sort the dropdown. Coding to add "ALL" is ok as long as you do not have to do it for too many dropdowns. Also, you do not need retrieve the dropdown, just get the handle to the dropdown using GetChild as Gajender suggests and insert a row. You will need code this in an event that gets fired only once. If not, you will end up adding "ALL" each time that event gets fired. I think "constructor" event is ideal as long as there no code to refresh your dropdowns elsewhere in the window. (Check getfocus, itemchanged  events to see if there any code to refersh dddws)
HTH

Namasi.
0
gajender_99Commented:
did it worked
let us know
0
NightManAuthor Commented:
Yes, it worked. Though I have an issue now. when I click on dropdown list I can see the "ALL" listed there. but if I select an other item in the list then go back to the drop down, I have still the "ALL" as marked. not the currently selected item.

I guess I am adding "ALL" each time as said by namasi. Can you please give me some more instruction for how to solve this?

*you guys seems to be good in powerbuilder, Any of you can help me on few more issues, which I need to complease today(I am newbee). Can I send the request by mail ? And seems to be both of you from south Asia, me is from there as well. :)
0
gajender_99Commented:
what you can do is just add  'ALL' at the time of opeaning the window or in in the constructor event of the data window where you have this drop down list
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NightManAuthor Commented:
ok will try that
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.