Filter between two dropdowndata windows

Hi,
I have a window that contains two dropdown datawindows calling from two procedures. I'm using PowerBuilder9

1.Function Desired: function     ( display value  : function_desc, data value : function)     fun1,fun2,fun3,fun4
2.corrected Code  : code_value ( display value : code_desc,      data value : code_value) cod1,cod2,cod3,cod4,cod5 and cod6

I need to filter in the second datawindow according to the first ddw selection.

If the user selects fun1 in drowdown(function desired) then I need to filter the 2nd ddw and shows only cod5,cod2 and cod6.
                           fun2 in drowdown(function desired) then I need to filter the 2nd ddw and shows only cod2.
                            fun3 in drowdown(function desired) then I need to filter the 2nd ddw and shows only cod1
                            fun4 in drowdown(function desired) then I need to filter the 2nd ddw and shows only cod1,cod2 ,cod3 and cod4.
I wrote the code in retreive event( window level) and itemchanged event ( dw level). But I am not able to do filter properly according to their selection.

I appreciate your help.
venkat4svAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sandeep_patelConnect With a Mentor Commented:
Hi,

it means you want hard coding... and fun1 to 4 and cod1 to 6 are datavalues not display values.
One more thing... here your main datawindow is tabular or freeform. I mean how many records will be dipslayed at a time. If it's free form and only single record will be displayed at a time following code will work fine. Otherwise you may need to do some workaround for display value. Becoz when you select fun1 in first row and and fun2 in second row it will affect display value of column code_value in both rows.

say your main datawindow is dw_1. Write code as below

Instance variable declaration
----------------------------------
datawindowchild idwc_fun, idwc_code

dw_1.constuctor event
--------------------------
This.GetChild('function',idwc_fun)
idwc_fun.SetTransObject(SQLCA)
idwc_fun.Retrieve()

This.GetChild('code_value',idwc_code)
idwc_code.SetTransObject(SQLCA)
idwc_code.Retrieve()

dw_1.ItemChanged Event
------------------------------

If This.GetColumnName() = 'function' Then
      Choose Case Data
            Case 'fun1'
                  idw_code.SetFilter("code_value = 'cod5' OR code_value = 'cod2' OR code_value = 'cod6'")
            Case 'fun2'
                  idw_code.SetFilter("code_value = 'cod2'")
            Case 'fun3'
                  idw_code.SetFilter("code_value = 'cod1'")
            Case 'fun4'
                  idw_code.SetFilter("code_value = 'cod1' OR code_value = 'cod2' OR code_value = 'cod3' OR code_value = 'cod4'")
      End Choose
      idw_code.Filter()
End If


Regards,
Sandeep
0
 
venkat4svAuthor Commented:
Thank you Sandeep, I got the result.
0
All Courses

From novice to tech pro — start learning today.