Установка значения в SelectBox - PullRequest
       9

Установка значения в SelectBox

0 голосов
/ 27 сентября 2019

Я пытаюсь установить значение в поле выбора, как показано ниже:

  <dx-select-box
            [items]="reportingProject"
            id="ReportingProj"
            [text]="reportingProject"
            [readOnly]="true"
            >

И объект reportProject находится в компоненте, подобном

constructor(private psService: ProjectShipmentService, private pdComp: ProjectDetailsComponent) {
   debugger;
   this.reportingProject = this.pdComp.rProjectNumber;
   this.projectSalesOrder = this.pdComp.rSalesOrder;

Несмотря на то, что в reportProject есть данные, которые он не показываетвверх на странице и поле выбора выглядит всегда пустым

Ответы [ 2 ]

1 голос
/ 27 сентября 2019

Как уже упоминалось в примере devexpress:

<dx-select-box
    [items]="simpleProducts"
    placeholder="Choose Product"
    [showClearButton]="true"
></dx-select-box>

, где simpleProducts - это массив строк:

let simpleProducts: string[] = [
    "HD Video Player",
    "SuperHD Video Player",
    "SuperPlasma 50",
    "SuperLED 50",
    "SuperLED 42",
    "SuperLCD 55",
    "SuperLCD 42",
    "SuperPlasma 65",
    "SuperLCD 70",
    "Projector Plus",
    "Projector PlusHT",
    "ExcelRemote IR",
    "ExcelRemote BT",
    "ExcelRemote IP"
];

Так что вам нужно привязать элементы к массиву например:

this.reportingProject = [this.pdComp.rProjectNumber];
1 голос
/ 27 сентября 2019

вы можете попробовать вот так

<dx-select-box id="myId" [items]="reportingProject" placeholder="my placeholder" [searchEnabled]="true" [(value)]="valueData" displayExpr="text" valueExpr="value" (onValueChanged)="onValueChange($event)">
</dx-select-box>

// items: must be a array or array of object 
// displayExpr: key of array of object which you would like to show on your selectbox
// valueExpr: value of your selectbox 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...