Move() Method of the ValueTable

The 1C:Enterprise developers forum

People who like this:0Yes/0No
Active user
Rating: 3
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:

Procedure MoveDown(Command)
    Index = Items.PricesTable.CurrentRow;
    If Index = Object.PricesTable.Count() - 1 Then
    Object.PricesTable.Move(Index, 1);
    Items.PricesTable.CurrentRow = Index+1;

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:
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?

People who like this:0Yes/0No
Timofey Bugaevsky


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:

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

And do not use your last line.

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.