Solved

datawindowchild arguments dependant on retrieval result in same datawindow

Posted on 2004-08-20
4
964 Views
Last Modified: 2013-12-26
Sorry if the title is confusing, but so is the topic.

I have a one to many relationship between two datawindows so that when you click on a row in dw_1 it shows multiple rows in dw_2.  I have a dwc field in dw_2 that has two arguments, one of which is dependant on the information that comes back when dw_2 is retrieved.  So I can't figure out how dynamically retrieve the data window for each row.

Essentially I am trying to show the number of notes that have been created for a particular provider as follows:

company c
                provider_1   provider_name  dwc_number_of_notes_for_provider (e.g. 6)
                provider_2   provider_name  dwc_number_of_notes_for_provider (e.g. 0)
                provider_3   provider_name  dwc_number_of_notes_for_provider (e.g. 4)

Here is the code, but I cannot figure out where to put it to make it work:

//            DWC to get number of notes for provider

            int rownbr3
            rownbr3 = tab_1.tabpage_1.dw_2.getrow()

            int sp_id3
            sp_id3 = getitemnumber(rownbr3, "service_provider_sp_id")

//            DataWindowChild dwc_provider_notes
            integer rtncode3
//            rtncode3 = tab_1.tabpage_1.dw_2.GetChild('sp_company_notes', dwc_provider_notes)
            rtncode3 = tab_1.tabpage_1.dw_2.GetChild('compute_1', dwc_provider_notes)

            messagebox("Return code is ", string(rtncode3))
            dwc_provider_notes.SetTransObject(SQLCA)
            //***MAY NEED MORE HERE
            long iii_row3
            iii_row3 = dwc_provider_notes.insertrow(0)
            //***
            int dwcrows3
            dwcrows3 = dwc_provider_notes.Retrieve(gv_effort_id,sp_id3)
            messagebox("Return rows are ", string(dwcrows3))
//            tab_1.tabpage_1.dw_2.settransobject(sqlca);

Perhaps there is an alternate way to do it.  Essentially, I just want a field to display a rowcount for table b that is based on information that in the same row.

Thank you,

Paul
0
Comment
Question by:pemurray
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Vikas_Dixit
Comment Utility
>>> So I can't figure out how dynamically retrieve the data window for each row
 if this means u want to retrieve the dddw for each row retrieved in dw_2, then it's not the correct way... because u retireve a dddw in the dw, and it applies to all rows.

what you can do is to retrieve the dddw after data is retrieved in the dw_2, and have another dddw( visible only for current row) that shows filterd record from the first dddw, depending on the row in dw_2.

Regards,
Vikas
0
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 500 total points
Comment Utility
....Essentially, I just want a field to display a rowcount for table b that is based on information that in the same row....

for this reason no need to take dropdowndatawindow. Following are the two ways to solve the problem.

1) create user defined function udf_getrowcount() which returns long and argument is what u r passing in dropdowndatawindow ( say arg1 and arg2 )

now in function write down

//-- function start
Long ll_rowcount
select count(*) into :ll_rowcount from table_name where col1 = :arg1 and col2 = :arg2 ;
return ll_rowcount
//-- function end

now put computed expression in dw_2 and writedown
udf_getrowcount(arg1,arg2) as a expression in it.

run the application and check it...it's done..

2) create a datawindow on required table with the syntax as described in solution 1, but without 'into :ll_rowcount'...define retrieval argument arg1 and arg2...assign in where clause...put this datawindow as a nested datawindow in dw_2...pass the argument to nested datawindow....that's it...

use any of the solution whatever is convininent to u...in case of any problem do reply...

have a nice day...

--sandeep
0
 

Author Comment

by:pemurray
Comment Utility
Sandeep,

Thank you,

This is my first time creating a user function so please bear with me...

I created the user function and named it: udf_getrowcount

Here is the code:

//-- function start
Long ll_rowcount
select count(*) into :ll_rowcount from service_provider_notes where effort_id = :gv_effort_id and sp_id = :sp_id ;
return ll_rowcount
//-- function end

The function painter whined a bit as the argument names are the same as two global variables, but it let me save it.

I created a computed field and typed this into the expression: udf_getrowcount(gv_effort_id , sp_id)

But I could not save the field because I keep getting the following error in the expression painter: ')' expected to close expression after function.

I spent quite a bit of time researching this but could not come up with an answer.

Thank you again for your help!!

Paul
0
 

Author Comment

by:pemurray
Comment Utility
Okay, I figured it out by using the colum names for the rows instead of the global variables as the arguments.  Doesn't make sense to me but I did get it done.  I notice that it is not as real time as I would like (e.g., you have to reretrieve after you do not to make it update the dw.  But I am happy with the solution.  Sandeep will get the point, thank you.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
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.

771 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

11 Experts available now in Live!

Get 1:1 Help Now