My goal is to retrieve data from the SQL server database and populate the corresponding fields on the frontend. While I am able to fetch the data, some fields in the response contain duplicate values in the dropdown menu. Here is an example of how my Component looks:
export class ReportingFilterComponent implements OnInit {
ShipmentList: ShipmentByProject[];
output= [];
entityUrl = 'ShipmentDetail/GetByReportingProject?repPrj=000634';
constructor(service: DataService) {
this.ShipmentList = [];
service.get<ShipmentByProject[]>(this.entityUrl).subscribe(x => {this.ShipmentList = x });
}
ngOnInit() {
var flags= [];
var l = Array.isArray(this.ShipmentList) ? this.ShipmentList.length : 0, i;
for( i=0; i<l; i++) {
if( flags[this.ShipmentList[i].customer_shipto_name]) continue;
flags[this.ShipmentList[i].customer_shipto_name] = true;
this.output.push(this.ShipmentList[i].customer_shipto_name);
}}
For testing purposes, I utilized the output
array in the HTML code:
Output data!
<li *ngFor="let out of output">
{{ out.customer_shipto_name }}
</li>
<div class="dx-fieldset">
<div class="dx-field">
<div class="dx-field-label">ShipTo Account</div>
<div class="dx-field-value">
<dx-select-box [dataSource]="ShipmentList" displayExpr="customer_shipto_name"></dx-select-box>
</div>
</div>
Despite having data in ShipmentList
, I do not see any results in the output
.
https://i.sstatic.net/w9KvS.png