Solved

dddw dropdown list with custom row!

Posted on 2003-12-10
29
763 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
ID: 9910902
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
ID: 9911078
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
ID: 9911173
no, I am using SYBASE and MSSQL
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 8

Expert Comment

by:gajender_99
ID: 9911256
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
ID: 9911306
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
ID: 9911351
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
ID: 9911418
select 'ALL' as code
union
select case_officer.code from case_officer

this should work
0
 

Author Comment

by:NightMan
ID: 9911483
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
ID: 9911539
is the officer code a numeric value or a string value
0
 
LVL 8

Expert Comment

by:gajender_99
ID: 9911545
or in the sql use can use the order by clause
0
 

Author Comment

by:NightMan
ID: 9911739
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
ID: 9911777
order by is not allowed by powerbuilder conflicting with union. and the value is string.
0
 
LVL 8

Expert Comment

by:gajender_99
ID: 9911796
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
ID: 9911857
not seems to be working, both are counted as code. there are no s_code in the properties
0
 
LVL 8

Expert Comment

by:gajender_99
ID: 9911884
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
ID: 9912102
What I have there is 2 "code". no "s_code" available in the list.
0
 

Author Comment

by:NightMan
ID: 9912107
yes, I already changed the SQL ofcourse.
0
 
LVL 8

Expert Comment

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

Expert Comment

by:gajender_99
ID: 9912367
can you send me you sql which you are using in dddw
0
 

Author Comment

by:NightMan
ID: 9912444
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
ID: 9912717
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
ID: 9912814
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
ID: 9912850
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
ID: 9912859
dw_client is your datawindow
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 9917580
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
ID: 9948514
did it worked
let us know
0
 

Author Comment

by:NightMan
ID: 9955826
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
ID: 9955920
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
ID: 9956858
ok will try that
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

856 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