Multi-Selecting Rows in Edit Tables in Order to Place the Selected Rows into Another Edit Table (Functions/Subroutines/Programs)
Created at 11 FEB 2000 04:08PM
This document was tested against OpenInsight v.3.72
Introduction:
To many, it becomes necessary or desirable to have the functionality that allows users to select multiple items in an edit table and from these selections, insert them into another edit table.
This desired behavior is similar to that seen in Form Designer Wizard. When the developer selects dictionary items from an edit table of available dictionary items, then clicks Add in order to add them to the form, it pops them into the next edit table of the Wizard.
The following demonstration provides sample code and instruction on how to produce such functionality. The default for edit tables is to not be capable of multiple selections (this is a Windows default), thus the need for an alternative method.
Demonstration:
1, Create an OpenInsight table called EDITMULT with the following:
a) A required key field called ID.
b) A non-required field called TABLE1, which is a non-required multi-valued field.
c) A non-required field called TABLE2, which is a non-required multi-valued field.
2. Create a form based on the OpenInsight Table called EDITMULT:
a) Add to the form the editline ID.
b) Add to the form the edit tables MULTI1 and MULTI2.
3. Your pre-rendered form should now appear. Add a button to the form and call it Add and give its text value Add . Also, if you d like to put your multi-selected Data into an editline instead/also, include the editfield EDITFIELD. Your form should appear similar as displayed below:
4. On the CREATE event of TABLE1, place the following code:
Declare function Get_Property, Utility
equ DTS_MULTIROW$ to 512
equ DTS_LARGEDATA$ to 4096
$insert PS_Equates
Record = Get_Property(@window:".TABLE1", "ORIG_STRUCT")
Val = Record<1,PSPOS_SDKSTYLE$>
if Val [1,2] _eqc "0x" then
convert @lower.case to @upper.case in Val
Val = iconv(Val [3,99], "MX")
end
Val = bitor(Val, DTS_MULTIROW$ + DTS_LARGEDATA$)
Record<1,PSPOS_SDKSTYLE$> = Val
/* destroy the old TABLE1 edit table and re-create it with a new STYLE property
which consists of multi-select and >64k of data capability */
old=Utility("DESTROY", @window:".TABLE1")
new=Utility("CREATE" , Record)
RETURN 0
5. On the ADD button, add the following code on it s CLICK event:
Declare subroutine set_property
declare function get_property
rows = get_property (@window:".TABLE1", "SELPOS")<2>
convert @vm to @fm in rows
cRows = Count(rows, @fm) +(len(rows)>0)
select =
for i = 1 to cRows
rowData = get_property (@window:".TABLE1", "CELLPOS", 0:@fm:rows<i>)
select := rowData:@fm
next i
*retrieve the highlighted data in a second edittable
select[-1, 1] =
set_property(@window:".TABLE2", "LIST", select)
*Alternatively, retrieve the highlighted data in an editline
convert @fm:@vm to ";!" in select
set_property(@window:".EDITFIELD", "TEXT", select)
RETURN 0
6. You can now Test Run the form. Enter in a key value and then data similar to the screen shot show on the next page. Now select multiple rows by left mouse-clicking on the row buttons, or alternatively, SHIFT+left mouse-clicking on the data rows themselves:
7. Now, simply click the Add button and your list of multiple rows will appear in the second edit table, TABLE2 (and/or delimited by ; in the edit lineEDITFIELD).
Conclusion: This concludes the demonstration Multi-Selecting Rows in EditTables to Place the Selected Rows into Another Edit Table.