home - For beginners
1c command form property using the current line.

How to install a line in 8.2 ( Managed Forms) read .

To begin with, I would like to remind you that the data in the tabular part of the document (or table of values) and the tabular field are different objects. In order to do some visual actions, we work with a table field. In this case, we will use its “CurrentRow” property, which is responsible for which row is active.

To select the row we need in the table field, we need two steps:

1. Find the row we need in the data object that the table field displays
I would like to emphasize that what is needed here is a data object. For example, we have a document Sales of Goods and Services which has tabular part“Products” and we decided to make the 2nd line active on the document form. Then in the document form module we will write:


// the second line has an index of one
RequiredString = Products;

Or we know that in the second line in the Nomenclature column the Code element is “001” then we use the construction:


// first find the directory element Nomenclature by code
// and then look for it in the “Products” tabular part
RequiredLine = Products.Find(Directories.Nomenclature.FindByCode("001"));

2. Set the value of the current line to the found line
Now we need to assign the value of the RequiredRow variable to the CurrentRow table field property:


// if our table field is also called Products
Form Elements.Products.CurrentRow = RequiredRow;

// if the table field is called TableField1

As a result, the lines of code may look like this:

RequiredLine = Products.Find(Directories.Nomenclature.FindByCode("001"));
Form Elements.TableField1.CurrentRow = RequiredRow;

Tabular parts exist for many objects in 1C:

  • Directories
  • Documentation
  • Reports and processing
  • Charts of accounts
  • Characteristic type plans
  • Calculation type plans
  • Business processes and tasks

Tabular parts allow you to store an unlimited amount of structured information belonging to one object.

Let's look at some techniques for working with tabular parts.

How to bypass the tabular part

To traverse the table part, you can use a loop For each

For each Row from the Tabular Part of the Cycle

Report(String. TabularPart attribute) ;

EndCycle ;

At each iteration into the variable Line the next row of the tabular section is transmitted. The values ​​of the row details can be obtained by the expression Line.AttributeName.

How to get and bypass selected rows of the tabular part

To display information from the tabular part of the object, use a form element Table field. To enable the ability to select multiple rows in a table field, you need to set the value Multiple at his property Selection mode.

To get a list of selected lines, use the following code:

To iterate through the selected lines, use a loop For each:

SelectedRows = FormElements. TableFieldName. SelectedRows;

For each Row from Selected Rows Loop

//loop contents

EndCycle ;

How to programmatically select rows of a tabular part (table field) and deselect them

To programmatically deselect rows of a table field:

Form Elements. TableFieldName. SelectedRows. Clear() ;

To programmatically select all rows of a table field:

For each CurrentRow From TabularPart Loop
Form Elements. TableFieldName. SelectedLines. Add(CurrentRow) ;
EndCycle ;

How to clear the table part

TabularPart. Clear() ;

How to get the current row of a table section

The current line is the period in which the user has this moment the cursor is located. To get it, you need to access the control element on the form that is associated with the tabular part.

For regular forms the code will look like this:

Form Elements. TableFieldName. CurrentData;

For managed forms:

Elements. TableFieldName. CurrentData;

How to add a new row to a table section

Adding a new line to the end of the table section:

NewRow = TablePart. Add() ;

Adding a new line anywhere in the table section (subsequent lines will be shifted):

NewRow = TablePart. Insert(Index)
//Index - number of the added line. Line numbering starts from zero.

New line. Props1 = "Value" ;

How to programmatically fill in the details of a table row

If you need to programmatically fill in the details of a table section row that is added by the user, you must use the table section event handler When StartingEditing.

The procedure created by the handler has three parameters:

  • Element- contains a control element TabularField.
  • New line- boolean. Contains value True, if added new line tabular part, and Lie, if the user started editing an already existing line.
  • Copy- boolean. Contains value True, if the user copies the line, and Lie in other cases.

Let's look at an example. Let's say we need to fill in the details of the tabular section AccountAccount, in case a new line is added. When editing an existing line, you do not need to change the accounting account.

Procedure TabularPartAtStartEditing(Element, NewRow, Copy)

//If the user edits an existing line, then we do nothing
If NOT NewRow Then
Return;
EndIf ;

//If the line is new, set the accounting account
TechString = Item. CurrentData; //Get the current row of the tabular part
TechString. Accounting = Charts of Accounts. Self-supporting. RequiredAccount;
EndProcedure

First you need to understand that there is an object that contains data, for example, Form DataCollection, and there is an object that displays data visually - a Table.

There is only the current row in the Table; it cannot be used to find out everything existing values FormDataThe collection with which it is associated. In turn, the FormDataCollection does not have a current row. To connect these objects in 1C, an Identifier is used, because the order of the rows can be changed both in the visual part and in the data, but the connection should not be broken.

Let's look at this with an example:

The form has a specification of type (Value Table) - in parentheses because the actual type is FormDataCollection

The details are displayed on the form in the form of a Table.

Defining a Value Table Row by Current Table Row

To determine which row of the TK is currently current, you must first get the row identifier in the Table, and then use it to find the row in the TK

RowIdentifier = Elements.TZ.CurrentRow; // Get the identifier in the Table LineTZ = TZ.FindByIdentifier(StringIdentifier);

Setting the current row in the Table

To set the current table row you need to do the opposite. First get the TK identifier, and then set the current row of the Table on it.

LineTZ = FormDataCollection; // for example, take line 1String Identifier = LineTZ.GetIdentifier(); Elements.TK.CurrentRow = RowIdentifier;

For easier understanding, you can download



 


Read:



Connecting an Android smartphone to a PC via Wi-Fi Connecting a phone to a PC via Wi-Fi

Connecting an Android smartphone to a PC via Wi-Fi Connecting a phone to a PC via Wi-Fi

How to connect an Android tablet or phone to a computer wirelessly. How to transfer files and watch videos from a PC. About the intricacies of data synchronization...

True RMS is the only correct measurement

True RMS is the only correct measurement

Introduction Measuring trueRMS of alternating voltage is not an entirely simple task, nor is it what it seems at first glance. First of all because...

Engineering samples Skylake (LGA1151) - Zionoviki

Engineering samples Skylake (LGA1151) - Zionoviki

The progress that Intel processors undergo when changing generations of microarchitecture has recently slowed down noticeably. Indeed, if...

Why magnetic cables for smartphones are dangerous and useful

Why magnetic cables for smartphones are dangerous and useful

The Mantis USB to USB Type-C nylon magnetic cable is a convenient and modern accessory designed to connect your smartphone to a charger...

feed-image RSS