Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise ā€“ Business applications platform > Move() Method of the ValueTable

Forum

Search UsersRules
Move() Method of the ValueTable
#1
Active user
Points:: 1
Joined:: Jul 20, 2011

1C:8.2, Managed Forms.
I need to manually arrange rows in the ValueTable. There is a method named Move(). It receives an index of the current row and the moving direction. I spent a lot of time to find the way to get an index of the current row and this is where I am:

Code
&AtClient
Procedure MoveDown(Command)
    Index = Items.PricesTable.CurrentRow;
    If Index = Object.PricesTable.Count() - 1 Then
        Return;
    EndIf;
    Object.PricesTable.Move(Index, 1);
    Items.PricesTable.CurrentRow = Index+1;
EndProcedure

Iā€™m doing the following: selecting a row which I would like to move (by clicking on it), clicking on the MoveDown button. The selected row is moving down, but the selection stays where it was. If I remove the last line:
Code
Items.PricesTable.CurrentRow = Index+1;

The selection moves, but the row index does not update. So when I click multiple times only two last rows do change places. How to fix it?

Profile
#2
Guest
Points::
Joined::

This is because CurrentRow returns not the row index, but the unique ID of the collection item. This ID is not assigned to the item position in the collection. Use the following code:

Code
RowID = Items.PricesTable.CurrentRow;
Index = Object.PricesTable.IndexOf(Object.PricesTable.FindByID(RowID));

And do not use your last line.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.