admin管理员组文章数量:1415484
I am trying to set a value on the select box like below
<dx-select-box
[items]="reportingProject"
id="ReportingProj"
[text]="reportingProject"
[readOnly]="true"
>
And the reportingProject is in Component like
constructor(private psService: ProjectShipmentService, private pdComp: ProjectDetailsComponent) {
debugger;
this.reportingProject = this.pdComp.rProjectNumber;
this.projectSalesOrder = this.pdComp.rSalesOrder;
Even though the reportingProject has data it doesnt show up in the page and the selectbox looks always empty
I am trying to set a value on the select box like below
<dx-select-box
[items]="reportingProject"
id="ReportingProj"
[text]="reportingProject"
[readOnly]="true"
>
And the reportingProject is in Component like
constructor(private psService: ProjectShipmentService, private pdComp: ProjectDetailsComponent) {
debugger;
this.reportingProject = this.pdComp.rProjectNumber;
this.projectSalesOrder = this.pdComp.rSalesOrder;
Even though the reportingProject has data it doesnt show up in the page and the selectbox looks always empty
Share Improve this question asked Sep 27, 2019 at 5:29 trxtrx 2,16710 gold badges61 silver badges105 bronze badges 5- Is dx-select-box custom made input? Or is that a package ponent? – MonkeyScript Commented Sep 27, 2019 at 5:31
- @Arcteezy It is from js.devexpress./Demos/WidgetsGallery/Demo/SelectBox/Overview/… – trx Commented Sep 27, 2019 at 5:32
-
Did you miss the closing tag i.e.
</dx-select-box>
– MonkeyScript Commented Sep 27, 2019 at 5:34 -
1
what does your
this.pdComp.rProjectNumber
returns? it should return an array – jitender Commented Sep 27, 2019 at 5:36 -
@trx
reportingProject
must be a array or array of object – Yash Rami Commented Sep 27, 2019 at 5:37
2 Answers
Reset to default 3you can try like this
<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
As mentioned in the Example of devexpress:
<dx-select-box
[items]="simpleProducts"
placeholder="Choose Product"
[showClearButton]="true"
></dx-select-box>
where simpleProducts is an array of strings:
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"
];
So you have to bind items to an array e.g.:
this.reportingProject = [this.pdComp.rProjectNumber];
本文标签: javascriptSetting the value on the SelectBoxStack Overflow
版权声明:本文标题:javascript - Setting the value on the SelectBox - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745233479a2648924.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论