Group columns

You can use this feature to create a collapsable group of columns.

Documentation


Methods

All methods related to row grouping.
MethodDescription
setColumnGroup(number, number) Create a new collapsable group of columns.
setColumnGroup(columnNumber: number, numOfItems: number) : void
resetColumnGroup(number) Reset the column group.
resetColumnGroup(columnNumber: number) : void
openColumnGroup(number) Open a group of columns.
openColumnGroup(columnNumber: number) : void
closeColumnGroup(number) Close a group of columns.
closeColumnGroup(columnNumber: number) : void


Events Settings

The following events related to row grouping.
PropertyDescription
oncreatecolumngroup When the user creates a group of columns
oncreatecolumngroup?: (worksheet: object, column: number, numOfItems: number) => void
onresetcolumngroup When the user destroys a group of columns
onresetcolumngroup?: (worksheet: object, column: number) => void
onopencolumngroup When the user opens a group of columns
onopencolumngroup?: (worksheet: object, column: number) => void
onclosecolumnroup When the user closes a group of columns
onclosecolumnroup?: (worksheet: object, column: number) => void


Initial Settings

It is possible to initiate the data grid with one or more groups of columns available for the user. There are two related properties to be used to this purpose.
PropertyDescription
group?: number The number of columns in the group
state?: boolean Initial state of this group. Default: false (closed)


Examples


Basic collapsable column group.

How to create a data grid collapse columns on Jspreadsheet.






Source code

<html>
<script src="https://jspreadsheet.com/v9/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v9/jspreadsheet.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id="spreadsheet"></div>

<input type="button" value="setColumnGroup(0,5)" onclick="spreadsheet[0].setColumnGroup(0,5)" />
<input type="button" value="resetColumnGroup(0)" onclick="spreadsheet[0].resetColumnGroup(0);" />

<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('NWQ1YTA2ZmE0MjhlYjAxOTk4NTU1ZjEzNzAwODg4M2IzZWYwZWQyOWQ4OTJkNWEzYjE4MzM2YmQxZjQ3MzA3MTJhMDYxMzcxNDczZjU3ZTM0YWNhODdmZTVjMzliNjg3MmMwYWUwZjcxOTNkZTY2MGUwZmE4MTg3NTJhNWViNmIsZXlKdVlXMWxJam9pU25Od2NtVmhaSE5vWldWMElpd2laR0YwWlNJNk1UWTVOalV3TXpVMk1Dd2laRzl0WVdsdUlqcGJJbXB6Y0hKbFlXUnphR1ZsZEM1amIyMGlMQ0pqYjJSbGMyRnVaR0p2ZUM1cGJ5SXNJbXB6YUdWc2JDNXVaWFFpTENKamMySXVZWEJ3SWl3aWQyVmlJaXdpYkc5allXeG9iM04wSWwwc0luQnNZVzRpT2lJek5DSXNJbk5qYjNCbElqcGJJblkzSWl3aWRqZ2lMQ0oyT1NJc0luWXhNQ0lzSW1Ob1lYSjBjeUlzSW1admNtMXpJaXdpWm05eWJYVnNZU0lzSW5CaGNuTmxjaUlzSW5KbGJtUmxjaUlzSW1OdmJXMWxiblJ6SWl3aWFXMXdiM0owSWl3aVltRnlJaXdpZG1Gc2FXUmhkR2x2Ym5NaUxDSnpaV0Z5WTJnaUxDSndjbWx1ZENJc0luTm9aV1YwY3lKZExDSmtaVzF2SWpwMGNuVmxmUT09');

// Create the data
// Data
var data = [];

for (var j = 0; j < 50; j++) {
    data[j] = [];
    for (var i = 0; i < 50; i++) {
        data[j][i] = jspreadsheet.helpers.getColumnNameFromCoords(i, j);
    }
}

// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
    worksheets: [{
        data: data,
        tableOverflow: true,
        tableWidth: '800px',
        tableHeight: '400px',
        columns: [{},{},{},{},{},{ group: 5, state: false }], // group 5 columns, collapsed
    }]
});
</script>
</html>