Hey.
It seems that some of the properties in the dataset, is not behaving the way i would think.
1: context.parameters.dataset.paging.totalResultCount is sometimes showing -1 (Is this property even supported?, it is in the typescript definitions)
2: Randomly, dataSet.paging.hasNextPage is undefined, while dataSet.loading is false, but all the records is not loaded into the dataset yet.
3: Sometimes, dataSet.paging.loading is true, but all records are in the dataset (create unnecessary extra dataload)
I have created this test script:
I have a view with 15500 records, and 15-20 % of the time, not all records are loaded into the dataset, am i missing something here?
public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container: HTMLDivElement) {
this.container = container;
var dataSet = context.parameters.Tasks;
if (dataSet.paging.totalResultCount > 0)
dataSet.paging.setPageSize(dataSet.paging.totalResultCount);
else dataSet.paging.setPageSize(5000);
}
public updateView(context: ComponentFramework.Context<IInputs>): void {
var dataSet = context.parameters.Tasks;
//Debugging
if (dataSet.loading) {
//If we know the totalResult, we can check if all are loaded
if (dataSet.paging.totalResultCount > 0) {
if (dataSet.sortedRecordIds.length != dataSet.paging.totalResultCount) {
console.log("Length not same as totalcount",{...dataSet})
return;
}
console.log("Length same as totalcount",{...dataSet})
}
//If the total result is unknown, we need to return to ensure all is loaded
else {
console.log("resuultCountUnknown",{...dataSet})
return;
}
}
else {
console.log("Dataset not loading",{...dataSet})
console.log("Has next page:", dataSet.paging.hasNextPage )
}
//if data set has additional pages retrieve them before running anything else
if (dataSet.paging.hasNextPage ) {
console.log({...dataSet})
dataSet.paging.loadNextPage();
this.count++;
console.log("Load count", this.count);
return;
}
console.timeEnd("dataload");
console.log("Count",this.count);
alert(dataSet.sortedRecordIds.length);
ReactDOM.render(React.createElement(App, { context }), this.container);
}