INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

(OP)
I have a window which is a questionnaire. It has a datawindow in it which displayed question and there is a dropdown list for each questions's answer to be selected by user.
Like question 1. Are you a school going? Answer drop down list can have answers like (DisplayColumn/DataColumn)
Yes/a_y
No/a_n
Now each question filters the answers dddw to fetch its corresponding answer list. but as soon as i click to other dropdown list to answer other question, the previous window displays data values instead of displaying text value.
i have created a function with below code which is getting called on each itemfocusedchanged event

idwc_answer.SetFilter("")
idwc_answer.Filter()

ls_question_code = dw_1.GetItemString(ai_row, "question_code")
ls_filter = "question_code='" + ls_question_code

idwc_answer.SetFilter(ls_filter)
idwc_answer.Filter( )

dw_1.Setfocus( )
dw_1.SetColumn("answer_code")

I have tried resetting display property using
dw_1.Modify("answer_code.dddw.DisplayColumn='answer_text'")
but it is destroying references of each dddw and i am not getting correct answers code.

Please help me if this can be done in PB 12.5
PFA image to see the layout of window
Link

RE: Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

Each dropdowndatawindow needs a separate datawindowchild reference and once that reference is set, the data retrieved, and filtered you shouldn't have to do anything else with it. When a dddw displays the data, that means that the value in the parent dw column does not match anything in the dddws list of values.

Are your list of questions dynamic somehow? If they are you need to filter the child datawindow based on the values of the parent when they are retrieved. If they are not, you should set a dddw reference for each row of the parent and filter the child datawindow. Remove the itemfocusedchanged code.

Matt

"Nature forges everything on the anvil of time"
www.anvil-of-time.com

RE: Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

(OP)
Yes, the questions list is dynamic. Based on the option selected on the parent window, there could be a different list of questions altogether.
I am calling my_filter function[with code mentioned above in my post] in itemfocuschanged event because for each question i need to filter out its corresponding answers list.
For eg
Ques 1 . Do you have a valid ID card?
Ans a. Yes
b. No

Ques 2 . Do you have a valid passport?
Ans a. Yes
. No

Is there any way to filter answers list based on questions list while retrieving the data for the first time itself?

RE: Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

Try the following:
In the Datawindow for your answer dropdown list:
1. Add a text field to the Header Band for a question code, such as t_question_code.
2. Add a computed column to the Detail Band, such as c_showrow, using the following expression: if(describe(“t_question_code.Text”) = question_code,1,0) (where question_code is the column with the question code value for the answers)
3. In the Position for the DisplayColumn set the following expression for the Y coordinate: if(describe(“t_question_code.Text”) = question_code,4,0) (where “4” is the current Y coordinate value)
4. In the Position for the DisplayColumn set the following expression for the Height coordinate: if(describe(“t_question_code.Text”) = question_code,76,0) (where “76” is the current Height coordinate value)
5. In the Position for the c_showrow computed column simply set the Position expressions for the Y and Height coordinates as “0” (zero)
6. Do not display any other columns in the Datawindow or set the Y and Height Position coordinates for any other displayed columns to the same expressions set for the DisplayColumn.
7. For the Detail Band set the Autosize Height checkbox on.
8. Add Sort criteria to the Datawindow. Sort first by the c_showrow computed column, setting the Ascending checkbox off to sort in descending order, followed by any other sort criteria you want for the answers.
9. Set the Height of the Header Band AND the Detail Band to zero.

In the Window containing the questions Datawindow add the following code to the RowFocusChanged Event of dw_1 (based on your example code):

ls_question_code = dw_1.GetItemString(al_row, “question_code”)
idwc_answer.Modify(“t_question_code.Text = ‘” + ls_question_code + ”’”
idwc_Sort()

What does all this do?
- The expressions in the Y and Height Position coordinates, and the Autosize Height flag on the Detail Band, cause only the rows for the question_code set in t_question_code to have a Height and thus be visible in the dropdown list. All other rows in the dropdown list will have a Height of zero.
- The code in the RowFocusChanged Event sets the t_question_code in the dropdown list to the question_code for that row, so when the answer dropdown list is opened it only shows the answers for that question code.
- The answers for all the other questions have not been filtered out of the list, so their display value will continue to appear on all the other questions.

You also need to add code similar to the code in the RowFocusChanged Event to whatever routine retrieves the questions to initialize the value of t_question_code in the answer dropdown list to the question code of the first question.

RE: Retaining DisplayCoulm value of dddw which is multiply used in a single datawindow

It's not that complicated :)

Simply duplicate the DDDW inside the DW which will give it a name - do NOT change the name. They both represent the same column and any change in one of them will reflect in the other one.

While the first DDDW will be used for editing and filtering available options in it based on the row, the duplicate DDDW will be used to display the display-values. For this to work, you do not filter the data in duplicate DDDW - it should contain all the values.

Overlay these two DDDW at the same location and make them visible/invisible based on:

Editable DDDW - if( getrow() = currentrow(), 1, 0)
Duplicate DDDW - if( getrow() = currentrow(), 0, 1)

HTH

Shekar Reddy
https://groups.yahoo.com/neo/groups/PowerObject/

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close