本帖最后由 dexteryao 于 2021-5-8 14:46 编辑
在SpreadJS数据透视表中提供了视图管理(ViewManager)的功能。
ViewManager和pivotTable是一对一关系,通过ViewManager,可以管理当前透视表的状态。
将当前视图状态保存,选取已保存的状态进行恢复,快速切换视图。
用户使用视图管理的功能,可以创建自己的视图方便使用,如果需要多种数据透视场景同时查看时,不需要创建多个数据透视表,只需要切换视图即可。
在SpreadJS 数据面板中提供了该功能,保存SpreadJS ssjson时,ViewManager中的数据也会序列化到json中,方便下次打开使用。
通过API也可以操作ViewManager,具体API如下
- ///* class GC.Spread.Pivot.PivotTable.PivotTableViewManager
- /**
- * Represents a PivotTableViewManager.
- * @class
- */
- views
- GC.Spread.Pivot.PivotTable.PivotTableViewManager
- /**
- * @description Add a view to pivot table views.
- * @param {string} view Indicates the view to add.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.add({
- * name: 'config1',
- * config: pivotTable.serialize()
- * });
- * viewsManager.get('config1');
- */
- add(view: IPivotTableView): boolean;
- /**
- * @description get all views from pivot table views.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.save('config1');
- * console.log(viewsManager.all());
- */
- all(): IPivotTableView[];
- /**
- * @description apply a view to current pivot table.
- * @param {string} name Indicates the name of view to apply.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.save('config1');
- * viewsManager.apply('config1');
- */
- apply(name: string): void;
- /**
- * @description get a view from pivot table views.
- * @param {string} name Indicates the name of view to query.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.save('config1');
- * viewsManager.get('config1');
- */
- get(name: string): IPivotTableView;
- /**
- * @description remove a view from pivot table views.
- * @param {string} name Indicates the name of view to remove.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.remove('config1');
- * viewsManager.get('config1');
- */
- remove(name: string): void;
- /**
- * @description Add a view to pivot table views.
- * @param {string} name Indicates the name of view to save.
- * @example
- * var viewsManager = pivotTable.views;
- * viewsManager.save('config1');
- * viewsManager.get('config1');
- */
- save(name: string): boolean;
复制代码
|
|