1s 8.3 cleaning conditional design of a dynamic list. Conditional styling of managed forms. Setting form properties

In this publication, we will look at an example of coloring lines of overdue documents in the document log (dynamic list) from the current date and current time.

Our task is to color the line pink if the Target Date is less than the Current Date, taking into account that the current date is constantly changing. That is, the current date must be read dynamically, and not determined upon first opening.

We'll learn how, in a controlled manner:

Use a wait handler;

Programmatically configure the conditional appearance of a dynamic list

Let’s say we have a “Smart Order” document with the “Control Date” attribute and the “Date” type (composition of the “Date and Time” date):

And the document journal “SmartOrder” with the column “Control Date” corresponding to this detail:

Our task is to color the row pink if the Target Date is less than the Current Date, taking into account that the current date is constantly changing.

Let's create a managed form:

Now, when creating on the server, we will call the procedure for coloring the lines “UpdatesDisplayOverdueOnServer”. And we will call this procedure with a given frequency.

Conditional styling of managed forms.

Most of those who have worked with access control systems and creating reports on access control systems know about conditional design firsthand. Changing a field's font, cell color, or presentation depending on the value in another field is already quite commonplace.

But we rarely encounter the conditional design of controlled forms. Although this is no less powerful, functional and necessary mechanism.
What is he like? But everything is the same. Based on any condition, we can configure the views or properties of the fields of tabular form elements and they will change right on the fly.

I'm talking about dynamic list fields and table fields. Here, from the code, we can access a separate column and set properties for the entire column at once, but we cannot set the properties of an individual field.

Quote

Important!!! Many people struggle with this and waste their time. Conditional styling does not work for regular form fields (not table fields).

Where can this be used other than coloring fields. Well, a classic example is the presentation of views in a tabular section. For accounting, there may be three of them as standard. And usually they are lined up in one field, one below the other. Since each line may have its own account, the composition of the analytics may differ. And in general, if you display 3 analytics in each line, it takes up a lot of space. Why do this if we are allowed to have one subconto somewhere, or two somewhere.

Setting form properties

Let's look at the example of a table section we created in processing.

Let's create a processing where we will add a tabular part with three Subconto details, and also add the Subconto Quantity attribute, which will indicate the number of subcontos in the line.

Setting up the conditional appearance of the form is located in the form properties on the Appearance tab.

Now our task is to indicate to the program that if the value in the line of the Quantity of Subconto field is 1, only Subconto1 should be displayed, with a value of 2: Subconto1 and Subconto2, with a value of 3: Subconto1, Subconto2, Subconto3.

To do this, use the conditional appearance settings form.

In the Formatted fields column, indicate the fields Subconto1, Subconto2, Subconto3. Since each field will have a different design, we will create 3 lines.

Let us indicate that we will formalize the visibility property.

We’ll also set up a condition under which visibility will be turned off.

Let's look at what happened in the enterprise. At the same time, we will add rows to the tabular part and arrange the values ​​of the number of subcontos.

As you can see, different numbers of fields are displayed in different lines.

Code setting

In addition to setting using properties, this setting can be done using program code.
If you use a configuration built on , it will look like this (this applies to all standard ones):

ElementUO = ConditionalDesign.Elements.Add();
DataCompositionClientServer.AddDesignableField(ElementUO.Fields, "TabularPartSubconto2");

GeneralPurposeClientServer.AddLayoutElement(ElementUO.Selection,
"TabularPartQuantitySubconto", DataCompositionComparisonType.Less, 2);

ElementUO.Design.SetParameterValue("Visibility", False);


If the BSP is not used, the code will be a little longer. I’ll just give standard procedures from the same BSP.

Function AddDesignableField(CollectionofDesignableFields,FieldName) Export

ElementField = Collection of FormattedFields.Elements.Add();
ItemField.Field = NewDataCompositionField(FieldName);

returnItemField;

EndFunction


Function AddLayoutElement(AddArea,
FieldName value,
Value Comparison Type,
Value RightValue = Undefined,
Value Representation = Undefined,
Value Usage = Undefined,
valueDisplayMode = Undefined,
valueUserSettingsIdentifier = Undefined) Export

Element = AdditionArea.Elements.Add(Type("DataComposition Selection Element"));
Item.LeftValue = NewDataCompositionField(FieldName);
Element.ComparisonView = ComparisonType;

If DisplayMode = Undefined Then
Element.DisplayMode = ElementDisplayModeDataCompositionSettings.Unavailable;
Otherwise
Element.DisplayMode = DisplayMode;
endIf;

If RightValue<>Undefined Then
Element.RightValue = RightValue;
endIf;

If Representation<>Undefined Then
Item.View = View;
endIf;

If Use<>Undefined Then
Item.Use = Use;
endIf;

// Important: ID setting must be done
// at the end of setting the element, otherwise it will be copied
// in user settings partially filled.
IfUserIdentifierSettings<>Undefined Then
Element.UserSettingsIdentifier = UserSettingsIdentifier;
ElseIf Element.DisplayMode<>ItemDisplayModeDataLayoutSettings.Unavailable Then
Item.UserSettingIdentifier = FieldName;
endIf;

Return Item;

We have some form of list, for example, of plan elements of the "User Rights" characteristic type in the "Manufacturing Enterprise Management" configuration version 1.3.

The form, as you can see, is manageable. we need to design the list in such a way that all rows of element groups are highlighted in green. Let's get started!

Example

Elements of managed forms are styled using conditional form styling:

To solve our problem, let's add a conditional design element with the following settings:


When you next open the form, the group rows of the characteristic type plan should be highlighted in green. But...this doesn't happen!


The fact is that the list of elements and groups of the plan of characteristic types is displayed on the form using a form object with the "Dynamic List" type. Dynamic lists take advantage of the data composition system's capabilities, including selections and conditional formatting. The latter determines the final design of the list, ignoring the settings of the conditional design of the form itself. Let's add similar conditional appearance settings for the dynamic list.


The only difference is that you need to add all visible fields of the list to the list of fields to be formatted to which the conditional design should apply.

Conclusion

I've often heard that conditional styling on managed forms doesn't always work. In the end, it turned out that you were simply making settings for the form, and not for the dynamic list.

I hope this article will save someone time when solving problems with conditional formatting.