Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Can you add a configuration interface for the pivot table? #4622

Closed
2 tasks done
Gdutyong opened this issue Feb 12, 2025 · 7 comments
Closed
2 tasks done

[Feature] Can you add a configuration interface for the pivot table? #4622

Gdutyong opened this issue Feb 12, 2025 · 7 comments
Assignees

Comments

@Gdutyong
Copy link

初始清单

  • 这真的是个问题吗?
  • 我已经在 Github Issues 中搜索过了,但没有找到类似的问题。

问题

数据透视表pivotTable有个getconfig api,能否出个setconfig api,直接把getconfig的数据设置回去来复原pivotTable,用已有的addField来复原pivotTable太麻烦了

@univer-bot univer-bot bot changed the title [Feature] 数据透视表能否添加一个设置config接口 [Feature] Can you add a configuration interface for the pivot table? Feb 12, 2025
@univer-bot
Copy link

univer-bot bot commented Feb 12, 2025

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Feature] 数据透视表能否添加一个设置config接口

Title: [Feature] Can you add a configuration interface for the pivot table?


Initial List

  • Is this really a problem?
  • I've searched in Github Issues but found no similar questions.

question

PivotTable has a getconfig API. Can you create a setconfig API? Set the getconfig data back to restore the pivotTable. It is too troublesome to use the existing addField to restore the pivotTable.

@VicKun4937
Copy link
Contributor

@Gdutyong Do you need config the fields in pivot table or the pivot table soure both?

// the config of a pivot tabe in sheet
export interface IPivotTableConfig {
    targetCellInfo: IPivotCellPositionInfo;
    sourceRangeInfo: IUnitRangeNameWithSubUnitId;
    themeId?: string;
   // the pivot table fields config, contains row, col, filter and so on.
    fieldsConfig: IPivotTableSnapshot;
    isEmpty: boolean;
}

I think is may be not a easy way for you to understand it, because there many ids need to match. can you use code or interface show what you want?

@Gdutyong
Copy link
Author

@Gdutyong Do you need config the fields in pivot table or the pivot table soure both?

// the config of a pivot tabe in sheet
export interface IPivotTableConfig {
    targetCellInfo: IPivotCellPositionInfo;
    sourceRangeInfo: IUnitRangeNameWithSubUnitId;
    themeId?: string;
   // the pivot table fields config, contains row, col, filter and so on.
    fieldsConfig: IPivotTableSnapshot;
    isEmpty: boolean;
}

I think is may be not a easy way for you to understand it, because there many ids need to match. can you use code or interface show what you want?

just want restore fieldsConfig,because user select fields and want to restore next time.

@VicKun4937
Copy link
Contributor

Maybe a clone config is useful for you , but it I think a reset api you also need, to ensure you pivot table is empty, as you know a same field in row or col may make mistake. A api like following may be works:

pivotTable.reset();
pivotTable.setFieldsConfig(fieldsConfig);

@VicKun4937
Copy link
Contributor

 /**
     * @description Set the pivot table fields config.It will add fields to the pivot table from provided config.Before setting the fields config, you should ensure the pivot table is empty to avoid the conflict.
     * @param {IPivotTableConfig['fieldsConfig']} config The pivot table fields config.
     * @returns {Promise<boolean>} Whether the pivot table fields config is set successfully.
     */
    setFieldsConfig(config: IPivotTableConfig['fieldsConfig']): Promise<boolean>;

    /**
     * @description Clear the fields by provided field area or clear all fields.
     * @param {PivotTableFiledAreaEnum} [resetArea] The area of the field to reset or undefined to reset all fields.
     * @returns {Promise<boolean>} Whether the pivot table fields are reset successfully.
     */
    reset(resetArea?: PivotTableFiledAreaEnum): Promise<boolean>

@VicKun4937
Copy link
Contributor

The code has merged, and you can get it next version (after 0.6.1)

@Gdutyong
Copy link
Author

The code has merged, and you can get it next version (after 0.6.1)

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants