Deleting an Item from a List

Visual LANSA

Deleting an Item from a List

Use the DLT_ENTRY command to delete the selected item in a list.

This example fills a list view with the employee and their salaries. When the push button "Delete" is clicked the selected employee is deleted from the List View:  

To see how the example works,  copy this code and paste it to a form component:

FUNCTION options(*DIRECT)

BEGIN_COM role(*EXTENDS #PRIM_FORM) HEIGHT(331) LEFT(245) TOP(136) WIDTH(620)
DEFINE_COM class(#PRIM_LTVW) name(#EMPLIST) DISPLAYPOSITION(1) FULLROWSELECT(True) HEIGHT(285) LEFT(8) PARENT(#COM_OWNER) SELECTIONSTYLE(Single) TABPOSITION(1) TOP(8) WIDTH(505)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_1) DISPLAYPOSITION(1) PARENT(#EMPLIST) SOURCE(#EMPNO) WIDTH(24)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_2) DISPLAYPOSITION(2) PARENT(#EMPLIST) SOURCE(#SURNAME) WIDTH(25)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_3) DISPLAYPOSITION(3) PARENT(#EMPLIST) SOURCE(#GIVENAME) WIDTH(33)
DEFINE_COM class(#PRIM_LVCL) name(#LVCL_4) DISPLAYPOSITION(4) PARENT(#EMPLIST) SOURCE(#SALARY) WIDTH(18)
DEFINE_COM class(#PRIM_PHBN) name(#PB_DELETE) CAPTION('Delete') DISPLAYPOSITION(2) ENABLED(False) LEFT(528) PARENT(#COM_OWNER) TABPOSITION(2) TOP(8)
EVTROUTINE handling(#com_owner.Initialize)
SET com(#com_owner) CAPTION(*component_desc)
SELECT fields(#EMPLIST) from_file(PSLMST)
ADD_ENTRY to_list(#EMPLIST)
ENDSELECT
ENDROUTINE
EVTROUTINE handling(#PB_DELETE.Click)
DLT_ENTRY from_list(#EMPLIST)
* Following would be RDML to delete the record from the physical file
* and to do any file validations
ENDROUTINE
EVTROUTINE handling(#EMPLIST.ItemGotSelection)
SET com(#PB_DELETE) ENABLED(TRUE)
ENDROUTINE
END_COM

 

Ý 6.15.8 Working with Items in Lists