Column visibility
Control and toggle the visibility of table columns for a more flexible user experience.
Example
Id
Name
Category
Price Retail
Id
Name
Category
1
Oriental Silk Bacon
Home & Garden
2
Gorgeous Gold Fish
Home & Garden
3
Ergonomic Plastic Cheese
Sports
4
Oriental Bronze Shirt
Electronics
5
Fresh Ceramic Sausages
Electronics
6
Soft Steel Mouse
Sports
7
Ergonomic Steel Mouse
Sports
8
Modern Ceramic Table
Home & Garden
9
Sleek Concrete Car
Clothing
10
Refined Plastic Towels
Electronics
Per page:
Page 1 of 100
Showing
1
to
10
of 1000 rows
[
{
"columnId": "id",
"visible": true,
"hideable": true
},
{
"columnId": "name",
"visible": true,
"hideable": false
},
{
"columnId": "category",
"visible": true,
"hideable": true
},
{
"columnId": "price.retail",
"visible": false,
"hideable": true
}
]
{#each datagrid.columns.getLeafColumns() as column}
{
datagrid.handlers.column.toggleColumnVisibility(column.columnId);
}}
/>
{column.header}
{/each}
{#each datagrid.columns.getLeafColumns() as column}
{@render LeafHeader(column)}
{/each}
{#each datagrid.rows.getPaginatedRows() as row}
{#each datagrid.columns.getLeafColumns() as column}
{#if column.isVisible()}
{#if !row.isGroupRow()}
{/each}
{getCellContent(column, row.original)}
{:else}{/if}
{/if}
{/each}
{JSON.stringify(
datagrid.columns.getLeafColumns().map((c) => {
return {
columnId: c.columnId,
visible: c.state.visible,
hideable: c.options.hideable
};
}),
null,
2
)}
{column.header}