1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 27 (2:10). Form development techniques. Calculated columns in lists

Calculated columns in lists

You might want to display custom data in list columns. For example, you might want to add a column with a calculated value.

We will explain this feature using the following example: displaying effective prices in the MaterialsAndServices catalog list.

You can get this data from the Prices.SliceLast information register table. So the Price field of the table should be added to the List dynamic list, which is the main attribute of the materials and services list form and serves as a data source for the list table.

In Designer mode

Let us add the prices to the list of materials and services.

  1. In Designer, open the list form of the MaterialsAndServices catalog.
  2. Open the property palette of the main List attribute.

    Up to this point the Main table property of the dynamic list was set to Catalog.MaterialsAndServices (see fig. 27.10) and the list was generated using a query to the table.

    Now you also need the related data from the Prices.SliceLast information register table.
  3. Select the CustomQuery check box and then, in the List setup field, click Open (fig. 27.16).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.16. Opening dynamic list settings

    This opens the dynamic list settings window. On the Query tab you can see the query that selects all the fields from the Catalog.MaterialsAndServices table. Let us modify it.
  4. Click the Query Builder button (fig. 27.17).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.17. Creating a custom query for a dynamic list
  5. Add Prices.SliceLast to the list of tables and select the Price field from this table (fig. 27.18).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.18. Adding a second table

    Let us edit the automatically generated relation between the tables.
  6. On the Links tab, select the All check box for the Catalog.MaterialsAndServices table and clear the All check box for the Prices.SliceLast table (fig. 27.19).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.19. Specifying the relation between the tables

    This is how you specify that the list of materials and services displays all the items, including those that have no prices assigned. You performed similar steps in lesson 13 "Reports" for the Service list report.

    This completes the query creation.
  7. Click OK.

    You are already familiar with the query script so we will not discuss it here.

    So you added the option to display the Price column, which contains the current prices, in the list of materials and services, but the column is not yet added to the list form.

    Now let us specify the conditional appearance of the Price column by highlighting low prices with a color.
  8. In the dynamic list settings window, click the Settings tab.
  9. Click the Conditional appearance tab.

    This tab contains the conditional appearance of the list rows that you created earlier in this lesson.
  10. Click the Add Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode button.

    First, let us specify the formatting for highlighting fields.
  11. In the Format field, click the selection Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode button  and select blue text color.

    Then let us specify the condition for the appearance to be applied (when the text in the Price column should be blue).
  12. In the Condition field, click the selection button Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode.
  13. In the window that is opened, click the Add Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode button and then click New item.
  14. In the Left value column, select Price.
  15. In the Comparison type column, select Less than.
  16. In the Right value column, enter 500 (fig. 27.20).

    Finally, let us specify the fields where the formatting is applied.
  17. In the Formatted fields column, click the selection button Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode.
  18. Click Add Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode and select Price (fig. 27.20).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.20. Dynamic list conditional formatting settings 
  19. Click OK.
  20. Drag the Price field from the attributes pane to the controls pane (fig. 27.21).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.21. Adding a column to the list form

    Now let us specify individual properties for each conditional appearance settings item.
  21. In the dynamic list settings window, on the Settings tab, click the first settings item and then click the Custom settings item properties Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode button.
  22. Select the Include in custom settings check box, set Presentation to Services, and in the Edit mode field, leave the Quick access value.
  23. Click OK.
  24. For the second settings item, select the Include in custom settings check box, set Presentation to Low price, and in the Edit mode field, leave the Quick access value.
  25. At the bottom of the tab, set the general Editing mode property to Normal (fig. 27.22).

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In Designer mode
    Fig. 27.22. Conditional appearance settings item properties

In 1C:Enterprise mode

Let us test the changes.

  • Start 1C:Enterprise in the debug mode and open the list of materials and services.

    You can see that materials and services are accompanied by their current prices, prices under 500 are displayed in blue color, and rows that represent services have lavender background.

    Both conditional appearance settings are displayed above the list of materials and services, they have human-readable names, and you can easily enable or disable them (provided that you remove the general setting that adds the backgound color, if it is still present in the user settings), fig. 27.3.

    Lesson 27 (2:10). Form development techniques / Calculated columns in lists / In 1C:Enterprise mode
    Fig. 27.23. List of materials and services with the specified formatting

Finally, note the Auto save user settings property of a dynamic list (see fig. 27.16). It is enabled by default.

This is why, once a user closes the form, its list settings are saved to a system storage, and once this user opens this form again, the settings are loaded from the storage. In addition to that, users can save list settings manually with custom names by clicking Save settings or Select settings on the More menu. You can use this feature to store multiple settings options for a single list.

You can also revert to the list settings specified by a developer in Designer by clicking Set default settings on the More menu.

Leave a Reply

Your email address will not be published.

 

1C:Enterprise Developer's Community