Page 1 of 1

VLWeb CheckBox in a list

Posted: Tue May 30, 2017 10:31 am
by soa
I have a checkbox column in a list control and I've added a click event to it. My issue is that the checkbox always returns unchecked when clicked regardless of what I can see on the screen.

Evtroutine Handling(#ChkReviewed.Click)

#sys_web.console.log( ('Reviewed=' + #ChkReviewed.ButtonState) )

Endroutine

returns

Reviewed=UNCHECKED
Reviewed=UNCHECKED
Reviewed=UNCHECKED
Reviewed=UNCHECKED

when clicked on and off multiple times.

Any ideas?

Re: VLWeb CheckBox in a list

Posted: Tue May 30, 2017 5:59 pm
by Stewart Marshall
Hi Jim

The ButtonState property of a CheckBox column is the prototype state for all entries when added to the list. This is why it doesn't change.

To access the item that's just been clicked, you need to use the column's CurrentItem.ButtonState

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Height(688) Width(816)
Define_Com Class(#PRIM_LIST) Name(#List1) DisplayPosition(1) Left(45) Parent(#COM_OWNER) TabPosition(1) Top(19) Height(366) Width(316)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnXDEMONUMB1) ColumnWidth(134) DisplayPosition(1) Increment(1) Parent(#List1) Source(#xDemoNumber) Wrap(False)
Define_Com Class(#PRIM_LIST.CheckBox) Name(#ColumnCheckBox1) ColumnWidth(78) DisplayPosition(2) Parent(#List1)
Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Label1') DisplayPosition(2) Ellipses(Word) Height(25) Left(392) Parent(#COM_OWNER) TabPosition(2) TabStop(False) Top(75) VerticalAlignment(Center) Width(201)

Evtroutine Handling(#COm_owner.CreateInstance)

Begin_Loop Using(#xDemoNumber) To(10)
Add_Entry To_List(#List1)
End_Loop

Endroutine

Evtroutine Handling(#ColumnCheckBox1.Click)

#Label1 := #List1.CurrentItem.Entry.AsString + " " + #ColumnCheckBox1.CurrentItem.ButtonState

Endroutine

End_Com
Regards