设置数据的方法是setDataSource本来就是基于sheet对象的
- var activeSheet = spread.getActiveSheet();
- var people = [
- {name: "Albert", isAdult: false, country: "American", website: "albert.com"},
- {name: "Alice", isAdult: true, country: "China", website: "alice.com"},
- {name: "Bob", isAdult: false, country: "Canada", website: "bob.com"}
- ];
- activeSheet.setDataSource(people);
复制代码
看你的意思就是点击哪个sheet页就去请求对应的数据组装好,再调用activeSheet.setDataSource就可以了
1、初始加载表格是默认就不要循环所有的sheet页去setDataSource了,可以做一个初始化动作:每一次都默认让它激活第一个sheet页,这样对应初始的时候只从后端拿第一个sheet页的数据源数据
2、配合切换sheet事件的监听进行你说的不同sheet页发起数据请求
- spread.bind(GC.Spread.Sheets.Events.ActiveSheetChanged, function (sender, args) {
- console.log("Active sheet has been switched.");
- });
复制代码 |