피벗 보기 관리자는 피벗 테이블의 저장된 보기를 관리하는 데 사용할 수 있습니다. 이를 통해 특정 시점에 피벗 테이블의 저장된 보기에 빠르게 액세스할 수 있습니다. 피벗 보기 관리자에서 보기를 추가, 삭제 및 수정할 수 있습니다.
피벗 테이블 패널 하단에 있는 '보기' 드롭다운에서 저장된 보기를 선택한 다음 해당 보기 옆에 있는 체크 표시를 눌러 보기를 변경합니다.
보기는 serialize() 및 deserialize() API를 사용하여 저장하고 복원합니다.
직렬화 및 역직렬화
직렬화는 현재 다음 데이터를 지원합니다.
필드 옵션 필터 정렬 레이아웃 피벗 테이블 위치 테마
인터페이스
interface GC.Spread.Pivot.ISerializeInfo
{
layoutType?: PivotTableLayoutType;
options?: object;
valuePosition?: GC.Pivot.IDataPosition;
pivotTablePosition?: [number, number];
fieldsInfo?: GC.Spread.Pivot.ISerializeFieldInfo[][];
}
interface GC.Spread.Pivot.ISerializeFieldInfo {
sourceName: string;
displayName: string;
index: number;
subtotal?: GC.Pivot.SubtotalType;
labelFilter?: GC.Spread.Pivot.IPivotTextFilterInfo | GC.Spread.Pivot.IPivotConditionFilterInfo;
valueFilter?: GC.Spread.Pivot.IPivotConditionFilterInfo;
sortInfo?: GC.Spread.Pivot.IPivotTableSortInfo;
}
API
///* function serialize (): GC.Spread.Pivot.ISerializeInfo
/**
* @description get serialized pivot table data
* @returns {GC.Spread.Pivot.ISerializeInfo} serialized pivot table data
*/
serialize (): GC.Spread.Pivot.ISerializeInfo
///* function deserialize (serializeInfo: GC.Spread.Pivot.ISerializeInfo)
/**
* @description restore serialized pivot table data to a existed pivot table
* @param {GC.Spread.Pivot.ISerializeInfo} serialized pivot table data
*/
deserialize (serializeInfo: GC.Spread.Pivot.ISerializeInfo)
샘플 코드
var spread = new GC.Spread.Sheets.workbook(document.getElementById("ss"),{sheetCount:3});
var sourceSheet = spread.getSheet(0);
var sheet = spread.getSheet(1);
var sourceData = [["Date","Buyer","Type","Amount"],
["01-Jan","Mom","Fuel",74],
["15-Jan","Mom","Food",235],
["17-Jan","Dad","Sports",20],
["21-Jan","Kelly","Books",125]];
sourceSheet.setArray(0, 0, sourceData );
sourceSheet.tables.add('sourceData', 0, 0, 5, 4);
var layout = GC.Spread.Pivot.PivotTableLayoutType.compact;
var theme = GC.Spread.Pivot.PivotTableThemes.medium2;
var pivotTable = sheet.pivotTables.add("pivotTable_1", 'sourceData', 1, 1, layout, theme, options);
pivotTable.add("Buyer","Buyer",GC.Spread.Pivot.PivotTableFieldType.rowField);
pivotTable.add("Type","Type",GC.Spread.Pivot.PivotTableFieldType.columnField);
pivotTable.add("Amount","Sum of Amount",GC.Spread.Pivot.PivotTableFieldType.valueField, GC.Pivot.SubtotalType.sum);
var serialization = pivotTable.serialize();
pivotTable.remove('Type');
pivotTable.deserialize(serialization);
PivotTableViewManager 피벗 테이블 보기를 추가, 삭제, 수정 및 확인하는 데 사용되는 피벗 테이블 보기 관리자
PivotTableViewManager와 피벗 테이블은 일대일 관계가 있습니다.
PivotTableViewManager는 피벗 테이블 구성자에서 초기화됩니다.
인터페이스
interface IPivotTableView{
name: string;
config: GC.Spread.Pivot.ISerializeInfo;
}
API
GC.Spread.Pivot.PivotTable
///* class GC.Spread.Pivot.PivotTable.PivotTableViewManager(applyCallback: Function, saveCallback: Function)
/**
* Represents a PivotTableViewManager.
* @class
*/
views
GC.Spread.Pivot.PivotTable.PivotTableViewManager
/**
* @description Add a view to pivot table views. A unique name is required when adding a view.
* @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: GC.Spread.Pivot.IPivotTableView): boolean;
/**
* @description Add a view to pivot table views. A unique name is required when adding a view.
* @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;
/**
* @description get all views from pivot table views.
* @example
* var viewsManager = pivotTable.views;
* viewsManager.save('config1');
* console.log(viewsManager.all());
*/
all(): GC.Spread.Pivot.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): GC.Spread.Pivot.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;
피벗 패널에서 "viewList"를 표시로 설정하면 보기 목록을 사용하여 피벗 테이블의 보기를 제어할 수 있습니다.
패널 맨 아래에 있는 보기 목록 섹션으로 보기를 추가, 제거, 적용할 수 있습니다.
"▼" 버튼을 클릭하면 보기 목록 대화상자가 표시됩니다.
보기 목록 대화상자에서 각 항목의 오른쪽에 있는 "x" 버튼을 클릭하면 해당 보기가 제거됩니다.
입력 대화상자에서 보기 이름을 입력하고 "+" 버튼을 누르면 보기가 추가됩니다.
입력 대화상자에 값이 없으면 기본 이름이 대신 사용됩니다.
보기 목록 대화상자에서 항목을 하나 클릭하면 입력 대화상자에 해당 보기 이름이 표시됩니다.
그런 다음 "√" 버튼을 클릭하면 보기에 해당 이름이 적용됩니다(피벗 테이블의 Deserialize() API).