Switches, regular application, managed forms. Switches, regular application, managed forms Customizing the appearance of a managed form by the developer

1C are created automatically by the system when using the application solution. They are the basis for presenting (displaying) information in the 1C:Enterprise system.

Structure of form 1C

Form B is a logical description of the composition of the form. elements describes what the form will look like. The placement of form elements is performed automatically by the system when it is displayed.

The displayed part of the form (visible to the user) is described as a tree that includes form elements (see the figure below, the “Form elements” field):

  • group including other elements,
  • input fields,
  • checkboxes,
  • switches,
  • buttons,
  • tables that include column elements, etc.

"Elements of 1C form"

[collapse]

A group of form elements can be represented as

  1. panel with frame,
  2. panel with pages (bookmarks),
  3. the page itself,
  4. command panel.

All functionality of the form is described as follows:

  • details (data the form works with);
  • commands (actions performed).

Customizing the appearance of a managed form

Customizing the appearance of a managed form by the user

The appearance of a managed form can be customized at the user level. For this feature, in the form actions there is a command “More” - “Change form” (managing only those form elements that are defined at the development stage or according to standard rules for form autogeneration).

"More" - "Change shape"

Command "More" - "Change shape":

After clicking “Change form”, the 1C form settings window is displayed:

[collapse]

In addition, in user mode it is possible to:


  • change the order of forms, move them from one column to another (if the desktop is organized in two columns), but you cannot change the number of columns on the desktop;
  • display information in the form of separate windows (when calling a navigation command, you need to hold down the Shift key).

If sections are used, then when you call a command in the navigation panel, the corresponding list is displayed in the work area, replacing the previous contents of the work area.

Customizing the appearance of a managed form by a developer

The developer can influence the arrangement of elements with various settings. It can determine the order of elements, specify their width and height, and also use:

  • commands of the form itself;
  • global commands used throughout the configuration;
  • parameterizable commands that will open other forms based on the specific data of the current form.

Figure (change of 1C form by developer)

[collapse]

When developing Form 1C you must:

  1. In the form editor, include the necessary details and commands in the form;
  2. create form elements that display them, determine the order of the elements, specify the width and height (if necessary);
  3. arrange elements into groups (if necessary).
  1. Use role-based visibility settings in form elements (viewing and editing details by , custom visibility of form fields by role, using commands by role) in the case of a large number of roles in the configuration (from several dozen). Instead, the following approaches should be followed:
    • when there are strong differences in the appearance and functionality of the form depending on the presence of certain roles for the user – develop separate forms, specialized for a specific set of user rights;
    • with minor differences - perform permission checks in code. It should be borne in mind that programmatic visibility control can reduce the speed of opening the form, which must be taken into account when choosing between the proposed approaches.
  2. Use role-based visibility settings in the configuration command interface, the main section command interface, and the start page work area. Instead, you should set permissions on sections of the command interface and objects included in the command interface or workspace. This makes the behavior of the managed interface more predictable for the user, and also makes it easier to investigate errors.

For more detailed information on working with forms, see the course “Working with forms in 1C:Enterprise 8.3”, http://www.1c.ru/rus/partners/training/uc1/course.jsp?id=161.

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 (List Selection Mode)

Selecting from another form (Select button)

Control buttons

The implementation of the above examples does not require significant effort on the part of the developer. for example, for the list mode it is necessary to fill the list of an element with values; to select from another form, it is enough to simply associate the control element with the directory data. But for the control buttons, you will need to write more code to process clicks on each button, although it will not be large:

Procedure pvSelection of NomenclatureRegulation(Element, Direction, StandardProcessing)
//Select data for the input field
// in this case, the Nomenclature directory
Request = New Request;
Request.Text=
"CHOOSE
| Nomenclature.Link As Product
|FROM
| Directory.Nomenclature AS Nomenclature
|ORDER BY
| Nomenclature.Code";
TZNomenclature = Request.Run().Upload();

//look for the current directory element specified in the input field
CurrentElement = TZNomenclature.Find(Element.value);

If TechElement = Undefined Then
// if the element is not found then set the index number
// outside the value table, because the very first element in
// value table has index 0
TechIndex = -1;
Otherwise
// if the element is found we get its index
TechIndex = TZNomenclature.Index(TechElement);
endIf;

// calculate a new index depending on the button press
// minus in front of the variable The direction is placed so that when
// clicking on the top arrow showed the element above it
// and therefore with a smaller index
NewIndex = TechIndex-Direction;

// get the number of elements in the directory
// subtract one because all collections in 8.1 start at 0
Number ofElements = TZNomenclature.Quantity()-1;

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

End of Procedure

Checkbox

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

Switch

The switch is used to select one value from a small number of possible ones (preferably no more than five), and the values ​​cannot 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 the discounts do not add up:

In this case, the convenience of using radio buttons 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 switches:

      The first switch should have the "FirstInGroup" property (in this example, it is the "5% Discount" switch).

      Switches that are meaningfully related to one group should go in a row when setting up the traversal order, without interruption by other form elements. The traversal order is set from the menu "Form -> Setting traversal order", for this example it looks like this:

  1. The type of selected value is set for the switch that has the "FirstInGroup" property.

Add a group frame to the form and place switches on it via the menu item Form -> Insert control... and select the switches in the window that opens:

In the right part of the window, add the switch value as much as we need, check the box “Promotions - first in group” so that this switch is selected automatically.

After we add the switches, we select the data type for the first value “Shares”, in our case we assign the value “Type of Securities”:

And the switch value itself is entered into Data -> Selected value. For Shares this is 0, Bonds - 1, Bills - 2 and Units - 3. But before entering this data, you need to check the order.

If the switches are not in order, then the switch will not be carried out, that is, we will not be able to select the value of the bond. In order to enable this feature, you must select the menu Form -> Setting traversal order and place all the switches in order.

Check the selectable value of the switches after correcting the order.

All that remains is to write the program code in the “action” switch event “On change”:

If CB Type = 0 Then

OtherwiseIfCBType = 1 Then

ThisForm.FormElements.Receipt.Columns.NCD.Availability = 1; // only for bonds we allow NKD

OtherwiseIfCBType = 2 Then

ThisForm.FormElements.Receipt.Columns.NCD.Availability = 0;

OtherwiseIfCBType = 3 Then

ThisForm.FormElements.Receipt.Columns.NCD.Availability = 0;

endIf;

Now, when you select the “Bonds” switch, you can edit the value of the asset column.

I read many forums, and nowhere did I see an intelligible description of working with the “Switch”. So I decided to write it myself.

In MY opinion, the most common mistake is the misconception about the “Switch”. When you place several “Switches”, for example 3, on a form, many people believe that in the program logic these are 3 different objects that influence each other. But, in fact, the program perceives all 3 “Switches” as one object. And choosing one of them changes the state of this object. Let's look at an example.

1. Create three radio buttons on the form. For convenience, we will not change the names.
2. Highlight Switch1. In its properties, in the “BASIC” section, check the first in group box. “VALUE TYPE” select a number. (Next we’ll look at why exactly the number). The length can be set to one, but this does not provide any special functionality.
3. Select “Switch2” in the “SELECTED VALUE” column and put 1.
4. Select “Switch3” in the “SELECTED VALUE” column and put 2.
Essentially, with actions 3 and 4, you set a flag that will change when you select the corresponding “Switch”. In “Switch1” the default “SELECTED VALUE” is zero.
5. Check whether the switches are in the “WALKING ORDER” in order. (for example: 13,14,15)(Fig. 1). a continuous order of traversal by switch is required. The auto-bypass order is enabled (positions are numbered 13, 15, 20) (Fig. 2) in this case, the switches under each other will not work. You should remove the use of auto-order from the form and, if necessary, manually specify the order.

How to set the traversal order for details. While in the form, in the "Dialog" menu, you need to uncheck the "Automatic traversal order" checkbox. After this, you can either use “Dialog” -> “Setting the traversal order”, or “Dialog” -> “Travel order”. The second method seems to me to be the most convenient. With this method, a picture with the prop number appears for each prop. All you have to do is click on the numbers, selecting the details in the order you need.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

6. Select “Switch1” and write the procedure we need for it.
For example:

EF=FormElements; If Switch1=0 Then EF.Payment Status.Value = "Unpaid"; OtherwiseIf Switch1=1 Then EF.Payment Status.Value = "Partially paid"; OtherwiseIf Switch1=2 Then EF.Payment Status.Value = "Paid"; endIf;

7. Press F7. Press F5. Let's see everything is working, we're great. And the big BOSS gives us a bonus.

EXPLANATION FOR THE CODE

Why is there "Switch1" everywhere? Since it has already been said, the program perceives all three elements as one, and since “Switch1” is the first in the group, then the program perceives it as the entire element. If you make “Switch2” the main one in the group, then the correctness check will need to be carried out according to "Switch2".
Well, where does "0", "1", "2" come from? We set those values ​​that the object takes when switching “Switches” in paragraphs 3 and 4.

AFTERWORD:

This code is given as an example of working with switches. In my opinion, this is more clear and understandable. But it’s worth mentioning that in “Value Type” you can immediately select what you need - a predefined value from a directory, an enumeration, for example, or a string value. That is, in the above example, it was possible to immediately assign the switches as values ​​not 0,1,2, but immediately “Unpaid”, “Partially paid”, “Paid”. And then the code will be reduced to one line:

Form Elements.Payment Status.Value = Switch1;

The result will be the same.

//////////////////////////////////////////////////////////////////////////////////////////

Switches in controlled forms (UF) have been made more intuitive.

When creating a Switch, you need to remember the duo Attributes, Form Element.
First of all, you need to create Form Attributes. You set the type of the attribute to what values ​​your switch will accept. I chose the String type. Here you have two options: if you created an Object attribute, then the value accepted by your switch will be saved in the database, if you simply add to the list of form details, then the result accepted by your switch will not be saved.

Next, drag and drop the Attributes we need into Form Elements. When creating a form element, the element in the "View" properties will have the type "Input Field". Select "Field switch" from the list. As a result, you will get a form something like this:


We fill in the title of the Form Element, color, font, location and other beauties to your taste.
There is an item in the properties of the form element. “Selection List” - in it you enter the Values ​​that your switch will take when selecting one or another item. In my example, I added lines with the values ​​“Record”, “Cancel Post”, “Post”.

After this, your switch is ready for use.

Depending on whether your switch is an Object attribute or a Form attribute, you use the following code to get the value stored in it:

SwitchFormElementFormElement // access directly if this is an attribute of the Object form.SwitchInsideDB // access through the Object element. to your details.

 
Articles By topic:
Switches, regular application, managed forms Customizing the appearance of a managed form by the developer
1C are created automatically by the system when using the application solution. They are the basis for presenting (displaying) information in the 1C:Enterprise system. Structure of the 1C form Form B is a logical description of the composition of the form. inventory elements
Your computer is broken: what should you do, repair it or buy a new one?
Many PC owners encounter various errors and malfunctions in their computer, but cannot determine the cause of the problem. In this article we will look at the main methods for diagnosing a computer, allowing you to independently identify and eliminate various problems.
How to get rid of a banner
After restarting the computer, the monitor displays a request to send a paid SMS, or to deposit money into a mobile phone account? Meet this, this is what a typical ransomware virus looks like! This virus comes in thousands of different forms and hundreds of variations. One
How to find out the size of folders on a disk using PowerShell
Most Windows users are used to the fact that the easiest way to get the size of a folder is to open its properties in Windows Explorer. More experienced ones prefer to use utilities such as TreeSize or WinDirStat. But, if you need to get more de