Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the dropdown datasource api call happening multiple times issue. #259

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading