Skip to content

Commit

Permalink
Fixed the dropdown datasource api call happening multiple times issue. (
Browse files Browse the repository at this point in the history
#259)

Co-authored-by: mashm <[email protected]>
  • Loading branch information
4manasa and mashm authored Dec 18, 2024
1 parent 77a51a7 commit 8f0ac6d
Showing 1 changed file with 29 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,39 @@ export class DropdownComponent implements OnInit, OnDestroy {

columns = preProcessColumns(columns) || [];
if (!this.displayMode$ && listType !== 'associated' && typeof datasource === 'string') {
this.getData(datasource, parameters, columns, context);
this.getData(datasource, parameters, columns, context, listType);
}
}

getData(datasource, parameters, columns, context) {
this.dataPageService.getDataPageData(datasource, parameters, context).then((results: any) => {
const optionsData: any[] = [];
const displayColumn = getDisplayFieldsMetaData(columns);
results?.forEach(element => {
const val = element[displayColumn.primary]?.toString();
const obj = {
key: element[displayColumn.key] || element.pyGUID,
value: val
};
optionsData.push(obj);
getData(dataSource, parameters, columns, context, listType) {
const dataConfig: any = {
columns,
dataSource,
deferDatasource: true,
listType,
parameters,
matchPosition: 'contains',
maxResultsDisplay: '5000',
cacheLifeSpan: 'form'
};
PCore.getDataApi()
.init(dataConfig, context)
.then((dataApiObj: any) => {
const optionsData: any[] = [];
const displayColumn = getDisplayFieldsMetaData(columns);
dataApiObj?.fetchData('').then(response => {
response.data?.forEach(element => {
const val = element[displayColumn.primary]?.toString();
const obj = {
key: element[displayColumn.key] || element.pyGUID,
value: val
};
optionsData.push(obj);
});
optionsData?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
this.options$ = optionsData;
});
});
optionsData?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
this.options$ = optionsData;
});
}

isSelected(buttonValue: string): boolean {
Expand Down

0 comments on commit 8f0ac6d

Please sign in to comment.