Solved

dddw dropdown list with custom row!

Posted on 2003-12-10
29
758 Views
Last Modified: 2013-12-26
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?
0
Comment
Question by:NightMan
  • 15
  • 12
  • +1
29 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
Comment Utility
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
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
no, I am using SYBASE and MSSQL
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
you can you it as show below then


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

Expert Comment

by:gajender_99
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
yea, but I am showing only one colum in the dropdown list.

here is the sql
SELECT case_officer.code  
    FROM case_officer
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
select 'ALL' as code
union
select case_officer.code from case_officer

this should work
0
 

Author Comment

by:NightMan
Comment Utility
ok, now it is showing up as the first line. but disapear in the list if i make a dropdown selection.
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
is the officer code a numeric value or a string value
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
or in the sql use can use the order by clause
0
 

Author Comment

by:NightMan
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
order by is not allowed by powerbuilder conflicting with union. and the value is string.
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
not seems to be working, both are counted as code. there are no s_code in the properties
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
What I have there is 2 "code". no "s_code" available in the list.
0
 

Author Comment

by:NightMan
Comment Utility
yes, I already changed the SQL ofcourse.
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
i would check this and get back to you soon
0
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
can you send me you sql which you are using in dddw
0
 

Author Comment

by:NightMan
Comment Utility
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
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
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
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
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
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
dw_client is your datawindow
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
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
 
LVL 8

Expert Comment

by:gajender_99
Comment Utility
did it worked
let us know
0
 

Author Comment

by:NightMan
Comment Utility
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
 
LVL 8

Accepted Solution

by:
gajender_99 earned 30 total points
Comment Utility
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
 

Author Comment

by:NightMan
Comment Utility
ok will try that
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now