Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can i create groups of cells?#5543

Discussion options

How can i manage groups? I would like to hide some columns or rows using a button

You must be logged in to vote
  1. Using Univer’s Built-in Group Plugin

Univer already has a GroupPlugin that lets you group rows/columns and collapse/expand them. Example usage:

import { GroupPlugin } from'@univerjs/sheets-group-ui';// Register the pluginuniver.registerPlugin(GroupPlugin);// Group rowsuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().group(2, 5); // groups rows 2-5// Collapse (hide) the groupuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().collapse(2);// Expand (show) the groupuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().expand(2);Same API existsfor columns viagetColumnManager().2. Manual Show/Hide via API```bashIf you don’t need f…

Replies: 1 comment 1 reply

Comment options

  1. Using Univer’s Built-in Group Plugin

Univer already has a GroupPlugin that lets you group rows/columns and collapse/expand them. Example usage:

import { GroupPlugin } from'@univerjs/sheets-group-ui';// Register the pluginuniver.registerPlugin(GroupPlugin);// Group rowsuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().group(2, 5); // groups rows 2-5// Collapse (hide) the groupuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().collapse(2);// Expand (show) the groupuniverAPI.getActiveWorkbook()?.getActiveSheet()?.getRowManager().expand(2);Same API existsfor columns viagetColumnManager().2. Manual Show/Hide via API```bashIf you don’t need full grouping, you can simply hide rows/columns directly:const sheet =univerAPI.getActiveWorkbook()?.getActiveSheet();// Hide rows 3–6sheet?.getRowManager().setHidden(3, 6, true);// Show them againsheet?.getRowManager().setHidden(3, 6, false);// Hide column B–Dsheet?.getColumnManager().setHidden(2, 4, true);// Show againsheet?.getColumnManager().setHidden(2, 4, false);3. Hooking into a ButtonLet’s say you have a buttonin your UI (outside the sheet). You can wire it like this:```bashconst toggleBtn = document.getElementById('toggle-columns');let hidden =false;toggleBtn.addEventListener('click', () => {  const sheet =univerAPI.getActiveWorkbook()?.getActiveSheet();  hidden =!hidden;sheet?.getColumnManager().setHidden(2, 4, hidden); // toggle col B–D});This way the user can click the button to hide/unhide the group.✅ Recommendation:If you want Excel-like grouping with expand/collapse icons, use the GroupPlugin.If you only want a custom hide/unhide button, use the manualsetHidden() API.
You must be logged in to vote
1 reply
@joaquinniicolas
Comment options

Thank you very much, that has resolved my question.

Answer selected byjoaquinniicolas
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
2 participants
@joaquinniicolas@Rosellines

[8]ページ先頭

©2009-2025 Movatter.jp