Answer the question
In order to leave comments, you need to log in
1C 8.2 - how to programmatically load data values from the directory into the field of the list of data values?
Good afternoon, tell me, please, an amateur, there is an arbitrary form on it field: SelectCity (List of values) field type: Directory.Link.Classifier
how to load data from the directory into a drop-down list?
Procedure OnOpen()
Запрос = Новый Запрос;
Запрос.Текст = "Выбрать Город Из Справочник.Классификатор";
Список = Новый СписокЗначений;
Список.ЗагрузитьЗначения(Запрос.Выполнить().Выгрузить().ВыгрузитьКолонку("Город"));
ЭтаФорма.ЭлементыФормы.ВыбратьГород.СписокВыбора = Список;
КонецПроцедуры
Answer the question
In order to leave comments, you need to log in
Your code does not fill in the field itself, but fills in a selection list - a list of values from which the user will be able to choose if the selection mode from the list is set.
By the phrase "does not work" it is not possible to understand what the problem is: is it impossible to fill in the selection list, or is it impossible to choose from it?
In the first case, the select list needs to be filled in, not replaced with your list of values.
Something like this:
ChoiceArray = Query.Execute().Upload().UnloadColumn("City");
ThisForm.FormElements.SelectCity.ChoiceList.LoadValues(ChoiceArray);
Look in the form field event helper syntax AtStartSelection and AtStartSelectionFromList (depends on field properties). And then StandardProcessing=false; and fill in the selection data. Do you have managed forms at all? If so, then it is better not to write queries in the context of the client
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question