1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 28 (2:00). Form customization techniques. Adding a tumbler switch to a form

Adding a tumbler switch to a form

An automatically generated material or service item form includes the MaterialServiceType field. Its values Material and Service are stored in the MaterialServiceTypes enumeration. The default field view is a text box where values are selected from a drop-down list.

If the number of enumeration items is small (2-3 items), you can display the field as a switch. A switch can have one of the following types: a set of radio buttons or a tumbler. The second option better suits modern application interfaces.

In Designer mode

Let us implement a switch.

  1. Create a custom form for the MaterialsAndServices catalog item.
  2. In the form controls tree, double-click the MaterialServiceType field.
  3. In the property palette, in the Type field, select Radio buttons.
  4. In the RadioButtonType field, select Tumbler.
  5. In the ChoiceList field, provide a list that consists of MaterialServiceTypes enumeration values (fig. 28.36).

    Lesson 28 (2:00). Form customization techniques / Adding a tumbler switch to a form / In Designer mode
    Fig. 28.36. Switch field property palette

    Let us also make another change. The Parent field stores the group where a catalog item belongs. And to move an item to the root of the hierarchy, a user should clear this field.

    However, the clear button Lesson 28 (2:00). Form customization techniques / Adding a tumbler switch to a form / In Designer mode is disabled by default. There are other ways to clear the field, such as using the mouse or pressing Delete, but some users really need this button. Let us enable it.
  6. In the Parent field property palette, in the ClearButton field, select Yes (fig. 28.37).

    Lesson 28 (2:00). Form customization techniques / Adding a tumbler switch to a form / In Designer mode
    Fig. 28.37. Text box property palette

    Note that text boxes have other properties that define button visibility: OpenButton, CreateButton, and more. The platform defines their visibility automatically but you can explicitly enable or disable them.

    After the changes the form preview should look as shown in fig. 28.38.

    Lesson 28 (2:00). Form customization techniques / Adding a tumbler switch to a form / In Designer mode
    Fig. 28.38. Catalog item form preview in the form editor

In 1C:Enterprise mode

Let us test the changes.

  • Start 1C:Enterprise in the debug mode and open any item of the Materials and services catalog.

    You can see that a tumbler switch is used for selecting between material and service. The selected value is displayed in green. And the Material or service group field has the Clear button (fig. 28.39).

    Lesson 28 (2:00). Form customization techniques / Adding a tumbler switch to a form / In 1C:Enterprise mode
    Fig. 28.39. MaterialsAndServices catalog item form in 1C:Enterprise mode

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community