Computers Windows Internet

1c picklist set value

Full syntax (click to expand)

List of Values

Description:

A list of values ​​is an object that is not saved in the database, which allows you to build dynamic sets of values ​​for solving interface problems and manipulate them (add, edit, delete elements, sort). It can be filled with values ​​of any type, i.e. the types of stored values ​​in the same list can be different. One of the examples of using this object can be the organization of the selection of a specific document from the list of possible documents, generated by a complex algorithm.

Collection items: ItemListValues

For an object, a collection traversal is available using the operator For everyone ... From ... Cycle... The traversal selects the elements of the collection.

It is possible to refer to a collection element using the [...] operator. The index of the element is passed as an argument ( numbering from 0).

Properties:

Methods:

Insert (Index, Value, View, Markup, Image) Inserts new item to the list of values ​​at the position with the specified index.SelectElement (Title, Element) Calls up a window for interactive selection of one of the elements included in the list of values. Element- the element to which the list of values ​​should be initially positioned during interactive selection. If the parameter value is not an element of the list of values ​​included in this list, positioning will not occur.Unload Values() Creates an array and copies the values ​​of the elements of the list of values ​​into it.Add (Value, View, Markup, Image) Adds a new item to the end of the list of values.LoadValues(ArrayValues) Loads a list of values ​​with values ​​from the passed array. In this case, all previous elements of the list are deleted.Fill in(Flag) Marks all items in a list of values.Index (Item) Gets the index of the item in the list of values. If not found, -1 is returned.Count () Gets the number of elements in the list of values.FindByValue(LookupValue) Searches for the value of an item in a list of values. If no element stores a value equal to the desired one, then the value is returned Undefined. FindBy ID(ID) Gets a list of values ​​item by ID. If the element is not found, then it returns Undefined. Check Items(Title) Marks or unchecks (interactively) the list of values ​​items. Returns True if the "OK" button is pressed in the dialog, Lie- otherwise.Clear () Clears the list of values ​​by removing all items from it.ShowSelectItem(DescriptionClose Alerts, Title, Element) Calls up a window for interactive selection of one of the elements included in the list of values.ShowTelementsLabel(DescriptionClose Alerts, Title) It is intended for interactive setting of the states of markings for the elements of the list of values.Get (Index) Gets the value at the index. Works in the same way as the operator.Shift (Element, Offset) Shifts the element of the list of values ​​forward or backward by the specified number of positions.Copy () Creates a copy of the list of values.Sort by Value(Direction) Sorts the list of values ​​in ascending or descending order of the values ​​stored by the elements. See example below.Sort By View(Direction) Sorts the list of values ​​in ascending or descending alphabetical order of the representations of the items in the list of values. See example below.Remove (Item) Removes an item from the list of values, where Element- the index of the element to be removed, or the element itself.

Constructors:

New List of Values
& OnClient Procedure ExecuteCode (Command) /// How to create a list of values ​​in 1c 8.3, 8.2 List = New List of Values; /// How to add an item to the list of values ​​in 1c 8.3, 8.2 // add method parameters:// - meaning // - performance // - mark (optional) // - picture (optional) List. Add (1980, // element value "Vasya's year of birth"// performance ) ; List. Add (1985, "Yulia's year of birth") ; // values ​​can be different types List. Add ("Polina", "Child's name"); /// How to insert an element into a list of values ​​in 1s 8.3, 8.2 // insert at position # 2 (elements are numbered starting from 0) // element with value 2010 and view // "Year of birth of their joint daughter" List. Paste (2, 2010, "The year of their joint daughter's birth") ; /// How to bypass elements of a list of values ​​in 1c 8.3, 8.2 For Each Element From The List Cycle Report (Element. Representation + ":" + String (Element. Value)); End of Cycle; /// How to clear the list of values ​​in 1s 8.3, 8.2 List. Clear (); List. Add ("Monday"); List. Add ("Tuesday"); List. Add ("Wednesday"); /// How to find out the number of elements of a list of values, as well /// get the element of the list by its index in 1s 8.3, 8.2 // numbering from zero For Index = 0 By List. Quantity () - 1 Cycle Report (List [Index]); End of Cycle; /// How to find a list item by its value in 1c 8.3, 8.2 ValueTuesday = List. FindByValue ("Tuesday"); /// How to find out the index of an element in a list in 1s 8.3, 8.2 Report (List. Index (SignificantTuesday)); // 1, since numbering is from zero /// How to sort the list by its values ​​in 1c 8.3, 8.2 // was: Monday, Tuesday, Wednesday List. Sort By Value (Sort Direction. Descending); // now: Wednesday, Monday, Tuesday /// How to remove an element from a list of values ​​in 1c 8.3, 8.2 // remove the first item // parameter: list item // or element index// you can do this List. Delete (List [0]); // or so // List. Delete (0); /// How to shift an element of a list of values ​​in 1s 8.3, 8.2 // move the zero element forward one position // was: Monday Tuesday List. Shift (0, 1); // became: tuesday monday /// How to make a copy of the list in 1s 8 Copy of List = List. Copy (); Colors = New List of Values; Colors. Add ("Red"); Colors. Add ("Green"); Colors. Add ("Blue"); /// How to unload the values ​​of a list into an array in 1c 8.3, 8.2 Array of Colors = Colors. UnloadValues ​​(); /// How to load list values ​​from an array in 1c 8.3, 8.2 Colors. LoadValues ​​(ArrayColors); End of Procedure /// How to make a modeless selection of a value from a list /// values ​​in 1s 8.3, 8.2& OnClient Procedure How toMakeNonmodalValueSelection (Command) Colors = NewList ofValues; Colors. Add ("Red"); Colors. Add ("Green"); Colors. Add ("Blue"); // procedure AfterSelectionElement is defined just below AlertAfterItemSelection = New Alert Description ( "AfterItemSelection", ThisObject); Colors. ShowItemSelect (AlertAfterItemSelection, "Choose your favorite color"); EndProcedure & OnClient Procedure AfterElementSelection (Item, Parameters) Export If Item<>Undefined Then Report (Element. Value); EndIf; End of Procedure /// How to mark values ​​from a list modelessly /// values ​​in 1s 8.3, 8.2& OnClient Procedure How to Make Non-ModalValuesClicker (Command) Colors = NewList; Colors. Add ("Red"); Colors. Add ("Green"); Colors. Add ("Blue"); // procedure AfterSelectElements is defined just below AlertAfterElementsClicker = New Alert Description ( "AfterCelementElements", ThisObject); Colors. ShowElementClick "Choose your favorite colors"); Colors. FillRemarks (True); EndProcedure & OnClient Procedure After Checking Items (Items, Parameters) Export If Items<>Undefined Then For Each Color From Elements Loop If Color. Checkmark Then Report (Color. Value); EndIf; End of Cycle; EndIf; End of Procedure /// How to make a modal selection of a value from a list in 1c 8.3, 8.2& OnClient Procedure How toModalValueSelection (Command) Colors = NewList of Values; Colors. Add ("Red"); Colors. Add ("Green"); Colors. Add ("Blue"); SelectColor = Colors. SelectItem ( "Choose your favorite color"); If VybColor<>Undefined Then Report (SelectColor. Value); EndIf; End of Procedure /// How to make a modal mark of values ​​from a list /// values ​​in 1s 8.3, 8.2& OnClient Procedure How to MakeModalValuesList (Command) Colors = NewList ofValues; Colors. Add ("Red"); Colors. Add ("Green"); Colors. Add ("Blue"); If Colors. Check Items ( "Choose your favorite colors") Then For Each Color From Color Loop If Color. Checkmark Then Report (Color. Value); EndIf; End of Cycle; EndIf; // but this is how you can set all the marks at once // list to a specific value Colors. FillRemarks (True); End of Procedure /// Download and run these examples on your computer

To open the selection form with selection in 1s 8.2(regular forms), we need to perform some actions. We'll get it first. After that, we will set the selection and open it programmatically, here is an example of the code:

Selection on the form in the input field 1C 8.2 with several values

In the example above, we looked at how to set selection on the selection form for a specific value. Now let's consider a situation when you need to substitute several values, it can be, for example, both an array and unloading from a query result. This is a selection in the input field 1c with multiple meanings.

To begin with, we get the selection form, in the parameters we pass the "Element" (owner), set the selection mode flag. Then we create a list of values ​​and an array, note that as a selection, when the type of comparison is set in the list, an object can only be present with the type List of Values... We add elements to the array, then load this array into the List of Values, which we subsequently set in the selection. Also, do not forget to enable the flag for using this selection, and set the Comparison View.

Setting the selection in the input field on the form in 1C 8.3, the StartSelection event

Now consider selection in the input field on a controlled form in 1C 8.3... Let's find on the form the element of interest to us, in which we will set the selection, in our case it is the field "Organization". We find the event "Select Start", click on the magnifying glass and find ourselves in the procedure. We see the ChoiceData parameter, this parameter is of the ValuesList type. In order to restrict the selection to the required elements, we need to fill in the List of Values. We can select elements only on the server, so we create a procedure with the & OnServer compilation directive. In this procedure, we fill in the Selection Data.

Very often it is necessary on the form to enable the user to select the settings on the form (before pressing the "Execute all" button). When you need to select one value from several predefined ones, a drop-down list of 1C values ​​on the form is often used.

Drop-down list of 1C values ​​on the form - add a selection field to the thick client form, specify its name. To prevent the user from changing the list - uncheck the "Edit text" checkbox in the properties of the selection field.

The selection list itself will be added programmatically in the "OnOpening" form handler. The select field has a subordinate list of valuesFormElements.ChoiceFieldName.ChoiceList, and to set a default value, and to define the selected valueFormElements.ChoiceFieldName.Value:
Open Procedure ()

FormElements.ValueSelection.ChoiceList.Clear ();
Form Elements.ValueSelection.ChoiceList.Add (0, "New Document");
Form Elements.ValueSelection.ChoiceList.Add (1, "Change document");
Form Elements.ValueSelection.ChoiceList.Add (2, "Delete document");
Form Elements.SelectValues.Value = 0;

End of Procedure

Drop-down list of 1C values ​​on the form - in the thin client on the form, you need to create a form attribute in which we will store the result, for example, with the string type. Drag it onto the shape.
Drop-down list of 1C values ​​on the form - Option 1)

  • Turn on the list selection button
  • In the Property "Picklist" click "..." and enter the options
  • The selection result will be saved in the selected attribute


Drop-down list of 1C values ​​on the form - Option 2)

  • Turn on the list selection button
  • Add the "StartSelectionFromList" handler

& OnClient
Procedure SelectedValueStartSelectFromList (Item, StandardProcessing)

Elements.SelectedValue.ChoiceList.Add ("Add document");
Elements.SelectedValue.ChoiceList.Add ("Edit document");
Elements.SelectedValue.ChoiceList.Add ("Delete document");

End of Procedure

The result is similar. Required if the list is to be filled with links to directories / documents that are not predefined.

Drop-down list of 1C values ​​on the form - Option 3)

This option works in a similar way, but the interface looks different.