Page 1 of 1

How to keep row position

Posted: Mon Jan 18, 2021 1:33 pm
by Taku Izumi
Hi,

When the UPD_ENTRY command is used to a list which is sorted, the position of the updated row changes.
Is there a way to keep the position of the row?
Pic1.png
Pic1.png (6.57 KiB) Viewed 13734 times
Pic2.png
Pic2.png (6.55 KiB) Viewed 13734 times
This is a sample code.

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>)

Define_Com Class(#PRIM_LIST) Name(#List1) Displayposition(1) Left(24) Parent(#COM_OWNER) Tabposition(1) Top(32) Height(486) Width(841)
Define_Com Class(#PRIM_LIST.String) Name(#ColumnSTD_STRNG1) Columnwidth(576) Displayposition(2) Parent(#List1) Source(#STD_STRNG) Sortonclick(True)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_NUM1) Columnwidth(90) Displayposition(3) Parent(#List1) Source(#STD_NUM) Columnreadonly(False)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_INT1) Columnwidth(105) Displayposition(4) Parent(#List1) Source(#STD_INT)
Define_Com Class(#PRIM_LIST.String) Name(#List1Column1) Columnwidth(39) Displayposition(1) Parent(#List1) Sortonclick(True) Source(#STD_ALPHA)

Define Field(#WRK_NUM) Reffld(#STD_NUM)

Evtroutine Handling(#Com_owner.Initialize)
#STD_STRNG := 'A'
Begin_Loop Using(#WRK_NUM) To(5)
#STD_ALPHA := #WRK_NUM.AsString
Add_Entry To_List(#List1)
End_Loop
Endroutine

Evtroutine Handling(#List1.ItemChanged)
#STD_INT := #STD_NUM * 10
Upd_Entry In_List(#List1)
Endroutine

End_Com

Best regards,
Taku Izumi

Re: How to keep row position

Posted: Mon Jan 18, 2021 2:15 pm
by Dino
Not seeing that problem in V15 EPC150020...

the value I entered still in the row 1, just my cursor now in the row 2 but the rows don't change. If you establish SortPosition instead of SortOnClick for the input column, yes, the row order could change.

If I click in the column heading of the first column, as I can see is a "sort on click column", the order will be reverse and yes, the first row will be last. If you click again the last will be the first again.

Re: How to keep row position

Posted: Mon Jan 18, 2021 2:20 pm
by Dino
Perhaps, are you thinking that the row number changes when the rows are sorted differently?
That wont be the case, is just the presentation.
This button and code can confirm the row number don't change when sorting the list:

Code: Select all

Evtroutine Handling(#Button.Click)
Selectlist Named(#List1)
#STD_STRNG := "This row is the number: " + #List1.CurrentItem.Entry.AsString
Upd_Entry In_List(#List1)
Endselect
Endroutine
End_Com

Re: How to keep row position

Posted: Mon Jan 18, 2021 6:59 pm
by Taku Izumi
Can you see same issue with the below steps?
1. Click the header of #ColumnSTD_STRNG1 to sort by ascending.
2. Change the value in the 1st row of #ColumnSTD_NUM1.
Then, the 1st row moves to the bottom of the list.

I want to prevent the behavior of row movement.
That is, I want to keep the 1st row at the top of the list.

Re: How to keep row position

Posted: Tue Jan 19, 2021 12:17 am
by Dino
Yes, I can see that effect now. very interesting.
My guess is that internally it is taking some kind of sortposition for each column based on their displayposition in the list, so once you have a larger value in the first row than the others, it moves it to the last.

I fixed this, at least for this example using SortPosition 1 and 2 in the columns STD_STRNG and STD_ALPHA, so even when you sort by the STD_STRNG (which in the example have the same value), the next column to be used to decide the order is now STD_ALPHA:

Code: Select all

Define_Com Class(#PRIM_LIST.String) Name(#ColumnSTD_STRNG1) Columnwidth(576) Displayposition(2) Parent(#List1) Source(#STD_STRNG) Sortonclick(True) Sortposition(1)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_NUM1) Columnwidth(90) Displayposition(3) Parent(#List1) Source(#STD_NUM) Columnreadonly(False)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_INT1) Columnwidth(105) Displayposition(4) Parent(#List1) Source(#STD_INT)
Define_Com Class(#PRIM_LIST.String) Name(#List1Column1) Columnwidth(39) Displayposition(1) Parent(#List1) Sortonclick(True) Source(#STD_ALPHA) Sortposition(2)
j18sortposition.jpg
j18sortposition.jpg (17.94 KiB) Viewed 13714 times

Re: How to keep row position

Posted: Thu Jan 28, 2021 6:34 pm
by Taku Izumi
I checked this issue to LANSA Support, and this was a defect.
But, I was able to solve this by set the std_alpha column to SortAsColumn property of the std_string column.

Code: Select all

Define_Com Class(#PRIM_LIST.String) Name(#ColumnSTD_STRNG1) Columnwidth(576) Displayposition(2) Parent(#List1) Source(#STD_STRNG) Sortonclick(True) Sortascolumn(#List1Column1)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_NUM1) Columnwidth(90) Displayposition(3) Parent(#List1) Source(#STD_NUM) Columnreadonly(False)
Define_Com Class(#PRIM_LIST.Number) Name(#ColumnSTD_INT1) Columnwidth(105) Displayposition(4) Parent(#List1) Source(#STD_INT)
Define_Com Class(#PRIM_LIST.String) Name(#List1Column1) Columnwidth(39) Displayposition(1) Parent(#List1) Source(#STD_ALPHA)

Re: How to keep row position

Posted: Wed Feb 03, 2021 11:26 am
by Taku Izumi
This is more better workaround.

Evtroutine Handling(#List1.ItemChanged)
#ColumnSTD_INT1.CurrentItem.Value := #STD_NUM * 10
Endroutine