Set the initial value in the input field 1s. Elements for entering list values. Adding elements to the form

IN new version 8.3.5 of the 1C: Enterprise platform there are many new changes and additions. Some of them have been described in the previous ones.

Create button while typing.

In the new 1C 8.3.5 the creation of new data items has been simplified.

When working with an input field, it is often necessary to create a new element. Therefore, the list below the input field was added a button to create a new item.

Now, if there is no desired item among the displayed items (for example, when opening a quick selection list), then the user, without leaving this formmay immediately create a new item... By clicking on the button for creating a new element, a form will open in which the necessary fields are filled in and then the user closes it, and a link to this element is automatically inserted into the input field.

This technique can be used in cases when it is known in advance that the required element is not in the database. For example, when a product arrived from a new supplier. Or when an initial seeding of the database is in progress.

And in a situation where the user is not sure whether the required element is in the database or not, everything becomes even more convenient now... For example, the user starts to enter the name and the system informs him that the required element is not in the database. Then you should press the button for creating a new element and the system itself will substitute the required name in the "Name of the new element" field. It remains only to press the button "Record and close".

This feature is available both in the new "Taxi" interface and in the old interface too.

Search by string.

IN "1C: Enterprise 8.3.5" seriously improved input by line, for which a new one was implemented powerful search engine in the input field... Now he can quickly work over the millions of records contained in the database.

Line-by-line input has got brand new possibilities.

Search can be performed anywhere in the line, and not only at its beginning. In this case, the user can type any fragments of words.

In large databases, full-text search allows you to quickly find suitable data for any of the words. It is also possible to search and in a few famous words, and unfinished words will be automatically completed with possible combinations.

If the amount of data is large, then it is possible to search using background job... Then an animated picture will be displayed for users next to the input field.

The form is controlled by means of various form elements, which are arranged hierarchically on the tab The elements form constructor. The most important element is the form itself, which is located at the top of the hierarchy of elements, and the rest of the elements are subordinate to it.

All form elements can be divided into five groups: fields, grouping elements, buttons, decorations, and tables. In my articles, I will analyze each of the groups. In this article, we will start to explore one of the types of field element - entry field, but before that, let's learn how to add an element to the form.

Adding elements to the form

This is done quite simply: you need to select the element The form in the Elements of the form designer and click on the "Add" button. After that, a window will open in which you need to select the desired type of element

After selection, the desired item will appear in the window The elements.

Managed form element Field

Parse a managed form element Field... This element is needed to enter information on the form. And also to display any information. After you add this element to the form, a palette of form element properties will open on the right. For now, you should be interested in two properties - Data Path and View.

In theDataPath property, the developer can associate the form element with the required form attribute. Note that after the element has been added Entry field on the form, it did not appear on the form itself. This happened because our new item is not associated with. For example, I have created on the processing form several attributes with different primitive types and one attribute with a reference type.

Now let's link our newly added form element to one of the attributes, for this we select the required attribute with the property of the Data Path element.

After that, the Data Path and View properties will be filled, and the element itself will be displayed in the form view.

Pay attention to the element property View... This property defines the functionality of the input field. You can choose different values \u200b\u200bfor this property.

Depending on the selected value, the functionality will be determined. In the pictures above, the value is selected - entry field, i.e. we can enter any values \u200b\u200bin this input field, and if we select a value text box, then we will not be able to enter anything.

This property value Viewinput fields are convenient to choose when you just need to show background information user.

Now let's add a new form element with the type Entry field and link it to the props RequisiteDate by means of the property PathKData already familiar to us

As you can see, the view of the input field has changed, as well as the possible choice of values \u200b\u200bfor the View property.

Thus, we conclude that the functionality of the input field depends on the type of props.

For props with type Boolean the following values \u200b\u200bof the View property will be available.

And other values \u200b\u200bof the View property will be available for an attribute with a reference type.

More details on how to work with form elements using practical examples is given in the book “Development Basics in 1C: Taxi. Developing a Managed Application in 12 Steps ”.

Sometimes it seems that learning a programming language in 1C is difficult and difficult. In fact, programming in 1C is easy. My books will help you easily and quickly master programming in 1C: and "Fundamentals of development in 1C: Taxi"

Learn programming in 1C with the help of my book "Program in 1C in 11 steps"

  1. No complicated technical terms.
  2. Over 700 pages of practical material.
  3. Each task is accompanied by a picture (screenshot).
  4. A collection of tasks for homework.
  5. The book is written understandably and simple language - for a beginner.

This book is suitable for those who have already started programming and are experiencing certain difficulties with this topic and for those who have been programming for a long time, but have never worked with 1C managed forms.

  1. No complicated technical terms;
  2. Over 600 pages of practical material;
  3. Each example is accompanied by a picture (screenshot);
  4. Book is sent to email in pDF format... Can be opened on any device!

15% discount promo code - 48PVXHeYu


If this lesson helped you to solve any problem, you liked it or turned out to be useful, then you can support my project by transferring any amount:

you can pay manually:

Yandex.Money - 410012882996301
Web Money - R955262494655

Join my groups.

1. Input field
2. Checkbox
3. Switch

Entry field

As a rule, an input field is associated with an object attribute and reflects its data. This is perhaps one of the most common elements, it has several ways to select a value:

Selecting from a List (ListSelect Mode)

Selecting from another form (Select button)

Regulation buttons

The implementation of the above examples does not require significant effort on the part of the developer so. for example, for the list mode, you need to fill the list of an element with values; to select from another form, you just need to bind the control with the data of the dictionary. But for the control buttons, you will need to write more code to handle pressing for each button, although it will not be large:

Pv procedure nomenclature selection control (element, direction, standard processing)
// Select data for the input field
// in this case the Nomenclature reference
Request \u003d New Request;
Request.Text \u003d
"CHOOSE
| Nomenclature.Reference As Item
| FROM
| Reference.Nomenclature AS Nomenclature
| ORDER BY
| Nomenclature.Code ";
TKNomenclature \u003d Request.Run (). Unload ();

// search for the current element of the directory specified in the input field
TekElement \u003d TZNomenclature.Find (Element.value);

If TekElement \u003d Undefined Then
// if the element was not found then set the index number
// outside the table of values, because very first element in
// value table has index 0
TekIndex \u003d -1;
Otherwise
// if an element is found, get its index
TekIndex \u003d TZNomenclature.Index (TekElement);
EndIf;

// calculate the new index depending on the button click
// minus before the variable Direction is used so that when
// clicking on top arrow the element above was shown
// and therefore with a lower index
NewIndex \u003d TekIndex-Direction;

// get the number of items in the directory
// subtract one since all collections in 8.1 start at 0
Number of Elements \u003d TZNomenclature. Number () - 1;

If NovIndex< 0 Или НовИндекс > Number of Elements Then
// if the index is outside the value table when changing
// i.e. its number is greater than largest index or less than 0 then
// don't change the value and inform the user about it
Report ("You have reached the limit of the directory");
Otherwise
// assign a new value, "Product" is the name of the column of the value table
Element.value \u003d TKNomenclature.Get (NewIndex) .Product;
EndIf;

End of Procedure

Checkbox

In most programs, the checkbox is used to display two states: checked, unchecked. In 1c the checkbox has three states, in the third state the checkbox is displayed - as set and at the same time shaded. The three states are available only if the checkbox data is a number, with the states having the following meanings:

Switch

The switch is used to select one value from a small number of possible ones (preferably no more than five), while the values \u200b\u200bcannot be combined, For example: suitable for selecting a person's gender. Another example: let's say a company gives one of 3 discounts on a product, and discounts are not summed up:

In this case, the convenience of using the switches may lie in the fact that each of them can have some value, which is set in the "Selectable value" property. And then "5% Discount" can store the value 5 or 0.05.

It's important to remember three things when using radio buttons:

      The first radio button should have the property "FirstInGroup" (in this example it is the "5% discount" radio button).

      Switches that belong to the same group in the setting of the traversal order should go one after another, without interruption by other form elements. The tour order is set from the "Form -\u003e Tour order settings" menu, for this example it looks like this:

  1. The type of the selected value is set at the radio button having the "FirstInGroup" property.

Print (Ctrl + P)

For application objects (directories, documents, charts of characteristic types, charts of accounts, charts of calculation types, registers, business processes and tasks, as well as exchange plans), in the Input by line property, you can specify the details by which the search is performed. If input by line is allowed (the corresponding details are specified), then it is permissible not to select from the object form in the input field of the corresponding type, but to enter the information that is contained in the specified object details.
For example, in the Nomenclature reference book, input by line is allowed for the name attribute. The directory has several names, which contains several products starting with the word Be. Then by entering in the input field
item substring Be, we will get a list of products that begin with this word Input by line

The requisites by which the search will be performed can be:
● For directories, charts of characteristic types, charts of accounts, charts of calculation types, exchange plans - Code and Name.
● For documents - Number.
● For business processes and tasks - Number and Name.
● Attributes of the Number or String type for which the Index property is set to Index or Index with add.ordering. An example of the latter is a field for entering an article, barcode, TIN.

Customizing line input

To form a list of details, you need to press the selection button and, in the dialog that opens, transfer to the left list those fields by which input by line can be made.


Customizing line input

If there are several fields, then set their order. When searching by string, the search is performed in the fields in the order in which they are shown in this dialog. For example, for the item of the Nomenclature catalog, the input can be carried out both by the code and by the article. If the value of the code of one element coincides with the value of the article of another, then the found values \u200b\u200bwill be included in the list in the order in which they were specified during setup.
ATTENTION! When searching for data (during string entry), data access restrictions apply.
In addition to specifying which fields will be searched for, the system allows you to further customize some search parameters. The String search method property is intended for specifying the string search method:
● Only at the beginning of the field selected for line entry (Start value). In this case, the search string is not split into words, and the entered text is searched entirely. For example, if the search is performed in the following data: Ivanov Maxim and Maximov, then when you enter the word Maxim in the input field, the data Maximov will be found, and when you enter in the Ivan Max input field, nothing will be found.
● In any part of the field (value Any part). If the search string consists of several words and the search is performed in any part, then the search uses a query similar to the following (for two fields and two words):

(Field1 LIKE “% Word1%” OR Field2 LIKE “% Word1%”) AND (Field1 LIKE “% Word2%” OR Field2 LIKE “% Word2%”)
Property Full text search allows you to use full-text search when organizing input by string. Full-text search cannot be used for tables in external data sources. Using full-text search has several features:
1. Full-text search is always performed at the beginning of words.
2. Full-text search is used for the initial selection of objects in which further search will be performed (the number of objects in which the search will be performed decreases).
3. All non-indexed links from the table used for line entry will be added to the full-text search results.
4. In the list of selected objects, a search will be performed by fields that are selected for use in the string input mechanism in the manner specified by the property String search method.
5. For each word from search query the “*” character is added at the end.
These features can lead to the following:
● Full-text search can overly narrow the search data set if you use any part search in conjunction with full-text search. As a result, the data will not be found. In this case, disabling full-text search will lead to finding the required data. This is because full-text search searches only at the beginning of a word. If the text you are looking for is not at the beginning of a word, input by line will not find such data.
● An out-of-date full-text search index can negatively impact search results.
● If the full-text search fails, the normal search will be applied according to the String search method property. This can lead to a situation when a found object turns into a not found one (for a search method for any part of a word). For example: the character "a" is entered in the input field, which is not only at the beginning, but also in the middle of the word array in which the search is performed. For a large dataset, full-text search will fail (search result is too large) and regular search will find data that contains the letter "a" inside. Then the user enters another letter (for example, "ts") and the search string becomes "ac". In this case, full-text search will select only the data that begins with “ac” and ignores the data that contains “ac” inside itself.
If the drop-down list is generated by the system (and not using program code applied solution), then representations of the found objects are formed according to a special algorithm. The representation of the found object consists of two parts: the representation of the attribute containing the search string (mandatory part) and additional presentation (optional part).
The actual presentation is formed as follows:
● The field containing the search string is determined:
● In the case of using full-text search or in a regular search by several words, such a field will be the first field from the list of fields specified in the Input by string property, in which the first word from the search string was found.
● When using a regular search by one word, this field will be the attribute in which the search was performed.
● The representation of the value located in a specific field will be a mandatory part of the representation of the found object for the drop-down list.
● It is determined whether or not it is necessary to generate an additional representation. For this, the composition of the fields is determined, which will be used to form an additional representation:
● If the found object has only one field used to form a presentation, and the search string is found in this attribute, the fields of the alternative presentation are used.
● Otherwise, the fields of the main view are used. The list of fields of the main and alternate representation is given below.
● If the list of fields for generating an additional representation is empty, the additional representation is not generated. Otherwise, the additional representation is formed as follows:
● Parentheses enclose the textual representation of all fields that are selected to form an additional representation, through “,“;
● The generated additional representation is added to the right, separated by a space, to the mandatory part of the representation of the found object.
● The following fields are used to form the main and alternative views:
● Directory, business process, chart of characteristic types, chart of accounts, chart of calculation types:
● Basic view: Name, Code.
● Alternate representation: Depending on which main representation is selected, the remaining field is used for the alternate representation.
● Document:
● Basic view: Number, Date.

● Task:
● Basic view: Name, Number, Date.
● Alternative representation: none.
● External data source:
● Main view: the field specified in the View field property of the external data source table.
● Alternative representation: none.
The Retrieve Selection Data Mode property controls how the platform searches for data as you type in a string. If the property is set to the Background value, then a background job is used to receive data, and an animated picture is displayed in the drop-down list, similar to the background execution of the report (see here). The background job is used if the required data is not received for display to the user within 200 ms. For file option information base it is possible to receive data in the background if no other background or scheduled job is running at the time of data retrieval. During background retrieval of selection results, the user can continue to edit the input field. Specifying the value Directly as the property value causes the search to be performed without using background jobs.
When customizing line input, it is recommended to follow these guidelines:
● It is recommended to set the Background value for the Selection data acquisition mode property for objects in which a large amount of data is planned.
● It is recommended to enable full-text search for objects in which a large amount of data is expected.
● Searching for a string anywhere is recommended to be included in conjunction with a background search, or in tables where a large amount of data is not expected. It is desirable, also with a large amount of data, if you enable search anywhere, then include full-text search (so that most of the searches would be performed through full-text search).

Features of the behavior of the input field

When entering data in the input field, you should take into account some peculiarities of working with the selection list. If, as a result of the set, several objects are found that begin with the entered text, then the list of these objects will be located in the drop-down list. While entering, the user can use the Up Arrow and Down Arrow buttons to move through the list, while continuing to type in the field itself. In this case, to make a selection, you need to select the required element and confirm the selection by pressing the Enter or Tab button. To form a list
selection for the input field, the following algorithm is used:
1. The data is retrieved when performing a search in the first field (from the list of selected fields) at the beginning of a string and by a substring. The number of records obtained as a result of a search by the beginning of a string will be called PC, and the number of records obtained as a result of a search by a substring will be called RP.
2. If RS + RP<=10, то в выпадающий список попадут все результаты каждого поиска.
3. If RP and RS are more than 5 (each), then 5 entries from each list will appear in the selection list.
4. If any of the values \u200b\u200bof РП or РС is less than 5, then all records from the smaller list and as many records from the larger list will be included in the drop-down list to add 10 to the drop-down list.
5. If the total number of entries in the drop-down list turns out to be less than 10, then we perform the algorithm from step 1 for the next field from the list of selected fields, using the difference between 10 and the number of results obtained as the number of data required for the next step.

Programming selection list

If the developer is not satisfied with how the selection list is formed, he can override it himself.
This can be done in two ways:
● Directly in the form - in this case, the special generation of the selection list will work only for this single field. To do this, you need to define event handlers for the StartSelection, AutoSelection and EndText Input.
● In the manager module of the corresponding object - in this case, a special formation of the selection list will be performed for all input fields in which the values \u200b\u200bof the used object are entered.
If the field is associated with data of the type of reference to an applied object (for example, ReferenceLink, EnumerationLink, etc.), then the selection list can be generated either in the manager module of the corresponding object, or using the form module handlers. In other cases, the selection list can only be generated using form module handlers.
Let's dwell on the second method in more detail.
To programmatically generate the selection list, you must redefine the event handler DataGettingDataProcessing Manager
object. The handler receives a set of parameters that determine the conditions for forming the selection list. The parameter set is
a structure that contains:
● Search string - a text string containing the text that the user entered into the input field. This property is always present (property
Search line).
● Filtering is a structure that describes the filtering as described by the filtering form parameter to expand the form for a dynamic list.
This property is always present.
The selection specified in this property will be converted (if possible) into a full-text search query, refining this query for
improve search speed.
● The property that specifies the mode of selecting groups and members (transmitted only for hierarchical lists) - the SelectorGroupsAndItems property.
● A property that determines how a string is searched: by the beginning of a word or by any part (the StringSearchMode property).
● The need to use full-text search (Full-textSearch property).
● Selection data acquisition mode (property SelectionDataAcquisitionMode).
● In addition, the structure contains elements that are specified in the properties of the form element - Links of selection parameters (see here) and Parameters
choice (see here).
In addition, a variable is passed to the handler, into which the generated selection list should be returned, and the StandardProcessing parameter,
which defines the behavior of the system after the handler exits.
If the developer sets the StandardProcessing parameter to False, then he needs to completely form the selection list himself.
If the checkbox for standard processing is set to True, then the system can be given the opportunity to generate a selection list, but if
This can be used to modify the selection parameters (add additional selection values, change the selection mode of groups and elements, etc.).
Note 1. If the system itself generates a selection list, data access restrictions are taken into account when forming the list.
Note 2. The examples below are not complete. They are intended to demonstrate various mechanisms for obtaining select lists.
So, the following code, in the case of any text entered by the user, will provide a choice of three products, with the codes 00000002, 00000003 and 00000004.
Example:

Procedure ProcessingDataGettingChoice(Selection Data, Parameters, Standard Processing)
ChoiceData \u003d NewList of Values;
(“00000002”));
ChoiceData.Add (Directories.Products.FindByCode(“00000003”));
ChoiceData.Add (Directories.Products.FindByCode(“00000004”));

Standard Processing \u003d False;
End of Procedure

In the following example, the selection that formed the input field will be expanded by setting an additional selection so that services will not be included in the selection list. In this case, the system takes over all the formation of the selection list.
Example:

Procedure
Parameters.Selection.Insert("View", Enumerations.Kinds of Goods.Product);
End of Procedure

As a final example, consider a simplified implementation of selection entirely by means of an embedded language. In this example, we will consider the selection of products, the name of which begins with the line entered by the user in the input field.
Example:

Procedure ChoiceDataGettingProcessing (ChoiceData, Parameters, StandardProcessing)
Request \u003d New Request;
Request.Text \u003d “SELECT ALLOWED
| Products.Link as Product
| FROM
| Directory.Products AS Products
| WHERE
| Products. Name LIKE & Name ";
Query.SetParameter("Name", Parameters SearchString + “%”);
Result \u003d Query.Run();
Results Table \u003d Result. Upload();
ArrayProducts \u003d ResultsTable.Download Column("Product");
Selection Data \u003d New List of Values;
SelectionData.LoadValues \u200b\u200b(ItemArray);
Standard Processing\u003d False;
End of Procedure

You should also pay attention to one more way of forming the selection list: passing as the value of the element of the list of values \u200b\u200bnot a reference to the desired object (as in the examples above), but a structure of special content.
This structure consists of the following elements:
● Value - the actual value of the selected item. A structure element with this name must be required.
● Deletion Flag - a flag that the selected value is marked for deletion in the infobase. A struct member with this name is optional.
● Warning - a line with the text of a warning that 1C: Enterprise will display when you select such an item from the list of values.
A struct member with this name is optional.
If the Deletion Mark property in the structure is equal to True and the Warning property is not specified, the system will automatically generate a warning text. If the Warning property is specified, then it is displayed. Remember that the Warning text ends with the question Continue? and is displayed as a question with options Yes and No.
Next, a modification of the previous example will be shown, in which a warning This warehouse should not be used will be generated for warehouses with the Do not use attribute set to True.
You can also combine both Structure values \u200b\u200band simple values \u200b\u200bin the same picklist.
Example:

Procedure ChoiceDataGettingProcessing (ChoiceData, Parameters, StandardProcessing)
Standard Processing \u003d False;
ChoiceData \u003d NewList of Values;
// Create a list with warnings
Request \u003d New Request;
Request.Text \u003d “SELECT
| Warehouses.Link,
| Warehouses.
| Warehouses. Do not use
| FROM
| Directory. Warehouses AS Warehouses ";
Result \u003d Query.Run ();
SampleDetailed Records \u003d Result.b ();
Until SampleDetailed Entries.Next () Cycle
Structure \u003d New Structure (“Value”,

In the course of the developer of an applied solution, the task of choosing a value from a predefined list may arise. In this case, the list of values \u200b\u200bcan be associated with some configuration data, or defined for the form. This task can be accomplished using the Select Box, List Box, and Input Box controls.
When Selection fields the user can actually select a value from the list. The list can be either linked to the data or defined as arbitrary for a given form through the option Lines of the selection list.
IN List boxthe user is shown a complete list of values, no need to expand the list to select the one he needs:

IN Entry field can be selected from data of reference type:

Question 10.49 of exam 1C: Platform Professional. You can use the following controls to select values \u200b\u200bfrom lists:

  1. Entry field
  2. Selection box
  3. List box
  4. Answers 2 and 3 are correct
  5. Answers 1, 2 and 3 are correct
The correct answer is the fifth, analysis above.

Question 10.64 of exam 1C: Platform Professional. Can you create an Input Box control at the same time along with a caption to represent the Text Box control?

  1. No, you can't, since these are different controls
  2. You can, for this you need to create an input field through the main menu item "Form-Insert Control ..."
  3. You can, for this you need to create an input field using the button of the same name on the "Controls" toolbar

The correct answer is the second:

Question 10.65 of exam 1C: Platform Professional. The "Input field" control is intended for:

  1. Entering values \u200b\u200bdirectly into the field, for example, from the keyboard
  2. Selecting object references
  3. Selecting values \u200b\u200bfrom a pre-formed list
  4. Answers 1, 2 and 3 are correct
  5. Answers 1 and 2 are correct

The fourth correct answer, all options are available.

Question 10.66 of exam 1C: Platform Professional. A thin dashed red line in the counterparty input field means:

  1. This field is not available for filling
  2. This field is required
  3. This field has a "FillVerification" event handler
  4. This field has one (or more) event handlers defined

The correct answer is the second - means obligatory.

Question 10.68 of exam 1C: Platform Professional.The composition of the buttons located to the right of the "Input field" control is determined by:

  1. The value of the input field property "Value type"
  2. By selecting the appropriate property in the control properties window
  3. By form
  4. Answers 1 and 2 are correct
  5. Answers 1, 2 and 3 are correct

The correct answer is the fourth. The first option is determined by the fact that not every data type can be opened, say, for viewing (for example, for enumerations). The second option also exists:

Question 10.70 of exam 1C: Platform Professional.What button do you need to create on the Input Field control so that you can use the drop-down list to select a value?

  1. Picklist button
  2. Selection button
  3. Regulation button
  4. There is no right answer

The correct answer is the first, the actual selection list button (triangle).

Question 10.71 of exam 1C: Platform Professional.Can I enter different types of values \u200b\u200binto the same edit control?

  1. It is impossible
  2. Yes, if it has a composite value type
  3. It is possible if it has a composite value type and the "Select type" property

The third correct answer is:

Question 10.73 of exam 1C: Platform Professional.Is the set of properties different for an edit control created in a form and located in a table box on that form?

  1. Differs
  2. Does not differ
  3. Differs unless they are fields of the same value type

The correct answer is the first, there are fewer options in the "table" input field, there is no section Usage:

Question 10.67 of exam 1C: Platform Professional. If "ReferenceLink.Nomenclature" is selected as the value type for the "Input field" control, is it possible to organize a quick selection of the value of this field by typing the name of a specific item of the item directly in the input field itself?

  1. No you can not
  2. Can. To do this, you must select the property of the input field "Autoselect empty"
  3. Can. To do this, select the property of the "Quick Select" input field
  4. Can. To do this, in the "Nomenclature" reference book editing window on the "Forms" tab, in the "Input by line" field, select "Name"