Move() Method of the ValueTable

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jul 20, 2011
Company:

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?

 
#2
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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.

 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.