Hi,
This might be a little difficult to explain.
I have a table which i display inside a dialog which uses PagingDataProviderView.
I need the collection to refresh every time I open or close the dialog.
function openDialog(event) {
if (!event.key || event.key !== "Tab") {
document.getElementById(`${vm.id}_dialog`).open();
if (vm.firstOpen) {
vm.reportSource(new PagingDataProviderView(
new CollectionDataProvider(vm.reportCollection()),
));
vm.firstOpen = false;
} else {
vm.reportCollection().refresh();
}
}
}
vm.ReportModel = Model.Model.extend({
idAttribute: "id",
});
vm.ReportCollection = Model.Collection.extend({
customURL: getURL,
model: new vm.ReportModel(),
parse: parseResponse,
customPagingOptions: pagingOptions,
fetchSize: vm.pageSize(),
});
vm.reportCollection = ko.observable(new vm.ReportCollection());
vm.reportSource = ko.observable();
This works fine as long as I don't make a selection on the table. Every time I open the dialog, the collection refreshes.
However, if I make a selection and open the dialog again, the collection gets stuck in a refresh loop.
The backing service for the collection is called multiple times and returns the exact same data.
If I close the dialog while the refresh is stuck in a loop, it stops calling the service and when i open it again, it calls the service just once and displays the data.
In the getURL method, when it works, the options parameter is a plain object.
When it goes into the infinite loop, every call to getURL sends a deferred object as the options parameter.
Does that mean the collection interface is not registering that the required records have been fetched?
I'm really confused. I have done something similar with a list view in a dialog and that seems to work without any trouble.
Thanks,
William.