Posted 4 March 2023, 10:47 pm EST
Dear Christina,
To enable the infinite scroll feature in Tablesheet, please follow these steps. First, add a table to the data manager of Spread using the dataManager.addTable(tableName, IDataSourceOption) method. Within the addTable() function, ensure that the sourceOption.remote.read property is a function that returns a Promise object containing the datasource.
When the TopRowChanged event is triggered, call the table.fetch(true) method. Once this method returns the Promise object, you can update the datasource and set the updated view on the Tablesheet. To achieve this, add the following event handler to your code:
spread.bind(GC.Spread.Sheets.Events.TopRowChanged, (e, args) => {
if (args.sheet.getViewportBottomRow(1) === args.sheet.getRowCount() - 1) {
products.splice(lastRowCount, 100, ...getProducts(100));
lastRowCount += 100;
myTable.fetch(true).then(() => {
let myView = myTable.views["myView"];
tableSheet.setDataView(myView);
});
}
});
Here, products is the array of data that you want to display, and lastRowCount is the index of the last row displayed on the Tablesheet. The getProducts() function retrieves the next set of 100 products to display.
To implement this feature, please refer to the attached sample. Additionally, you can find further information on dynamically changing datasources and the IDataSourceOption interface in the documentation links provided below:
Changing datasource dynamically: https://www.grapecity.com/spreadjs/docs/features/tablesheet/data-operations/change-datasource-dya
IDataSourceOption interface: https://www.grapecity.com/spreadjs/api/v15/modules/GC.Data#idatasourceoption
You can access the sample code at this link: https://jscodemine.grapecity.com/share/hQnUQ7dEqk_hpTTe5ou1eA/?defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"%2C"%2Fsrc%2Fdata.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}
I hope that the information provided proves useful in addressing your query. However, if you continue to encounter difficulties, please do not hesitate to share a minimal working sample along with your current implementation. You can fork this sample and provide us with the necessary details.
Please feel free to contact us if you have any further questions or concerns.
Best regards,
Ankit