cancel
Showing results for 
Search instead for 
Did you mean: 

Datawindow Dropdown - Is there a select all or multiple select option or workaround?

Former Member
0 Kudos

Datawindow Dropdown

Is there a select all and/or multiple select option for the datawindow dropdown feature?

I would be interested in information on how to implement a workaround or third party options.

Thanks, Wayne

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I have created own custom control to handle this situation. If you want you can try this.

1)  copy and paste the source in notepad save as uo_dw_dropdown_multiselect.sru name and import into your source.

2) Create a data window by inheriting the this object. and attach drowdrop control to  field in   datawindow control and make sure that your drop down datawindow object has first column as checkbox for selection.

2)  Sample Code

//Call to initialize the control  wherever you want

dw.uf_init_dw( )

// Pass the default values should display in the column

dw.uf_set_default( 'Default data values')

// Call this function to get the selected data in array.

dw.uf_get_selected_data( ls_data)

$PBExportHeader$uo_dw_dropdown_multiselect.sru
forward
global type uo_dw_dropdown_multiselect from datawindow
end type
end forward

global type uo_dw_dropdown_multiselect from datawindow
integer width = 1006
integer height = 168
string title = "none"
boolean border = false
borderstyle borderstyle = stylelowered!
event ue_command pbm_command
end type
global uo_dw_dropdown_multiselect uo_dw_dropdown_multiselect

type variables

DatawindowChild idwc_list

string is_selected_data
string is_select_cln, is_display_cln, is_data_cln
string is_dwc_cln
string is_data[]
end variables

forward prototypes
public function integer uf_init_dw ()
private function integer uf_get_dwc ()
private function integer uf_get_column_names ()
private function integer uf_dwc_retrieve ()
private function integer uf_dwc_editable ()
public function integer uf_set_default (string ls_data)
public subroutine uf_get_selected_data (ref string as_data[])
public function integer uf_select_data ()
end prototypes

event ue_command;
// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Multiple select drop down
// -------------------------------------------------------------------------------------

DatawindowChild ldwc_ddlb
int li_rc

li_rc = this.GetChild( is_dwc_cln , ldwc_ddlb)

IF hwndchild = handle(ldwc_ddlb) THEN
 
CHOOSE CASE notificationcode
CASE 1281
  li_rc = ldwc_ddlb.getclickedcolumn( )
  if  ldwc_ddlb.Describe("#" + String(li_rc)  + ".name")  = is_select_cln then
   Post Event itemchanged( 1, this.object, '')
  End if 
END CHOOSE
END IF

end event

public function integer uf_init_dw ();

// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Initialize the control
// -------------------------------------------------------------------------------------


int  li_rtn

this.settransobject( sqlca)
this.insertrow( 0)

li_rtn = uf_get_column_names( )
li_rtn = uf_get_dwc()
li_rtn = uf_dwc_retrieve( )
li_rtn = uf_dwc_editable( )

Return 1
end function

private function integer uf_get_dwc ();// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Get the child
//             
// -------------------------------------------------------------------------------------

int li_rtn


li_rtn = this.getchild( is_dwc_cln  , idwc_list  )
idwc_list.settransobject( sqlca)

Return li_rtn
end function

private function integer uf_get_column_names ();// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  get the cln namedynamically
//             
// -------------------------------------------------------------------------------------


is_dwc_cln = this.Describe("#" + String(1)  + ".name")
is_display_cln  = this.Describe( is_dwc_cln + ".dddw.DisplayColumn")
is_data_cln = this.Describe( is_dwc_cln + ".dddw.DataColumn")

Return 1
end function

private function integer uf_dwc_retrieve ();// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Retrieve the dropdown child
//             
// -------------------------------------------------------------------------------------


long ll_row

ll_row = idwc_list.retrieve( )

Return ll_row
end function

private function integer uf_dwc_editable ();
// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Make the selection checkbox editable
//             
// -------------------------------------------------------------------------------------

string ls_modify_str

is_select_cln = idwc_list.Describe("#" + String(1)  + ".name")
ls_modify_str = is_select_cln +'.tabsequence =10'

idwc_list.modify(  ls_modify_str)
ls_modify_str = is_dwc_cln + ".dddw.UseAsBorder='YES'"
idwc_list.modify(  ls_modify_str)

Return 1


end function

public function integer uf_set_default (string ls_data);
// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Set the default values
// -------------------------------------------------------------------------------------

long ll_row
string ls_find
ll_row = idwc_list.rowcount( )

ls_find = is_data_cln +" = '" + ls_data +"'"

if ll_row > 0 then
ll_row = idwc_list.find( ls_find , 1 , ll_row )
if ll_row > 0 then
  idwc_list.setitem( ll_row, is_select_cln , 'Y' ) 
  uf_select_data( )
End if 
End if

Return 1
end function

public subroutine uf_get_selected_data (ref string as_data[]);
// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Get the selected data in array and return to calling function
//             
// -------------------------------------------------------------------------------------


as_data = is_data


end subroutine

public function integer uf_select_data ();

// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Get the selected data
// -------------------------------------------------------------------------------------

long ll_row_count , ll_inc, li_temp_count
string ls_empty_ary[], ls_temp_data
string ls_temp_selected

ll_row_count = idwc_list.rowcount( )
idwc_list.accepttext( )

is_selected_data = ''
is_data = ls_empty_ary
For ll_inc = 1 to ll_row_count
if idwc_list.getitemstring( ll_inc , is_select_cln) = 'Y' then
  li_temp_count++
  ls_temp_data = idwc_list.getitemstring( ll_inc ,is_display_cln )
  ls_temp_selected = ls_temp_data
  if len(ls_temp_data ) > 6 then
   ls_temp_data = left(ls_temp_data, 6) + '..'
  End if
  
  if li_temp_count = 1 then
   is_selected_data =  ls_temp_data
  Else
   is_selected_data = is_selected_data + ',' + ls_temp_data
  End if
  is_data[upperbound(is_data) + 1] = idwc_list.getitemstring( ll_inc ,is_data_cln )
End if 
Next

if li_temp_count = 1 then
is_selected_data = ls_temp_selected
End if

this.setitem( 1,  1 , is_selected_data)

IF li_temp_count = 0 then
  MessageBox('Selection', 'Atleast one type needs to be selected', information!)
  Return 1
End if
end function

on uo_dw_dropdown_multiselect.create
end on

on uo_dw_dropdown_multiselect.destroy
end on

event itemchanged;
// -------------------------------------------------------------------------------------
// Modified By  Date     Wl #  Description
// -------------------------------------------------------------------------------------
// Balu    27-OCT-2014  WL-334  Multiple select drop down
// -------------------------------------------------------------------------------------

uf_select_data( )
end event

Former Member
0 Kudos

Like the solution that Bruce gave you thru the PBDJ article, I have a solution that uses a LBX.  However, it is generic by using Describe(ls_columnName + '.DDDW.displayValue') to build the list and only requires the coding of the pbm_dwnDropDown event for the datawindow and the loseFocus event of the listBox.  It also resizes the lbx to match what PowerBuilder would display a DropDown and repositions it so that it actually looks like a DDDW.

I have contemplated adding it to the PFC, but haven't done much on the PFC project for a bit.

If you'd like, you can email me and I'll put together a commented list of the code for you and you can evaluate it for your needs.

Note that Bruce also asked a pertinent question, where will you put the data.  For my solution, I assume the data is a list of the selected values and is delimited by some character and returns the same.  I use code to take the list of values from the database and create a single column value on retrieve and code that breaks the list up when writing to the database.

Former Member
0 Kudos

HI Wayne;

Answer: No

WorkAround:

   Please a CommandButton beside the dropdown column and open a Response dialog with a Tabular or Grid DataWindow presentation format that allows the multi-select to occur. Close the Response dialog with a CloseWithReturn command and return a structure with all the selected items and/or their row numbers to be processed.

HTH

Regards ... Chris

former_member190719
Active Contributor
0 Kudos

A drop down datawindow isn't really a multi value option.  Where would you put the result?

That being said, you might look at this PBDJ article for how one person handled it.

Multi-Select Dropdown List Box-type Entries for DataWindows

http://pbdj.sys-con.com/node/480678?page=0,1