Data Table
<zn-data-table> | ZnDataTable
Short summary of the component’s intended use.
<zn-data-table empty-state-caption="No customers found" empty-state-icon="person_off" data-uri="/data/data-table.json" method="GET" headers="[{"key":"label","label":"ID", "required":true, "default": true}, {"key":"One","label":"Name", "required":true, "default": true, "sortable":true, "filterable":true}, {"key":"Two","label":"Name", "required":true, "default": true, "sortable":true, "filterable":true}, {"key":"Three","label":"Name", "required":true, "default": true, "sortable":true, "filterable":true}, {"key":"Four","label":"Name", "required":true, "default": true, "sortable":true, "filterable":true}]"> <zn-data-table-sort slot="sort"> <!-- Need to configure default, and available sort columns Future enhancement: allow multi-column sort !--> </zn-data-table-sort> <zn-data-table-filter auto-submit="true" debounce="1000" slot="filter"> <zn-input name="search" placeholder="Search customers..." icon="search" debounce="300" clearable></zn-input> </zn-data-table-filter> </zn-data-table>
Examples
Filter-top Slot
Add complex filtering options to the top of the table using the filter-top
slot.
Use the filters to search for products
<zn-data-table data-uri="/data/products-table.json" method="GET" no-initial-load headers="[{"key":"name","label":"Name"}, {"key":"category","label":"Category"}, {"key":"price","label":"Price"}, {"key":"discountPercentage","label":"Discount %"}, {"key":"stock","label":"Stock"}, {"key":"rating","label":"Rating"}]"> <zn-empty-state slot="empty-state" icon="inventory_2" caption="No products found"> <p>Use the filters to search for products</p> </zn-empty-state> <zn-filter-wrapper slot="filter-top" button="Submit"> <div class="form-spacing"> <zn-input type="price" name="price" label="Price" span="3"></zn-input> <zn-select name="category" span="3" label="Category" clearable> <zn-option value="beauty">Beauty</zn-option> </zn-select> <zn-button type="primary" submit>Search</zn-button> </div> </zn-filter-wrapper> </zn-data-table>
Filter-top Slot with Tabs
Add complex filtering options to the top of the table using the filter-top
slot.
<zn-data-table data-uri="/data/products-table.json" method="GET" headers="[{"key":"name","label":"Name"}, {"key":"category","label":"Category"}, {"key":"price","label":"Price"}, {"key":"discountPercentage","label":"Discount %"}, {"key":"stock","label":"Stock"}, {"key":"rating","label":"Rating"}]"> <zn-panel flush-x slot="filter-top"> <zn-tabs> <zn-navbar slot="top"> <li tab>Quick Search</li> <li tab="product">Product Search</li> </zn-navbar> <zn-sp gap="sm"> <zn-filter-wrapper with-submit> <zn-form-group label="Quick Search" label-tooltip="Quickly filter results in the table" help-text="Use the fields to filter results in the table, then click Search"> <zn-input type="price" name="price" label="Price" span="3"></zn-input> <zn-select name="category" span="3" label="Category" clearable> <zn-option value="beauty">Beauty</zn-option> </zn-select> </zn-form-group> </zn-filter-wrapper> </zn-sp> <zn-sp id="product" flush-y> <zn-filter-wrapper with-submit> <zn-filter-builder filters="[{"id":"title","name":"Title","operators": ["eq"]}, {"id":"category","name":"Category","options":{"beauty":"Beauty"},"operators":["eq"]}]" name="query"> </zn-filter-builder> </zn-filter-wrapper> </zn-sp> </zn-tabs> </zn-panel> </zn-data-table>
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@1.0.7/dist/components/data-table/data-table.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@1.0.7/dist/components/data-table/data-table.js';
To import this component using a bundler:
import '@kubex/zinc/dist/components/data-table/data-table.js';
Slots
Name | Description |
---|---|
(default) | The default slot. |
example
|
An example slot. |
Learn more about using slots.
Events
Name | React Event | Description | Event Detail |
---|---|---|---|
zn-event-name |
|
Emitted as an example. | - |
Learn more about events.
Custom Properties
Name | Description | Default |
---|---|---|
--example |
An example CSS custom property. |
Learn more about customizing CSS custom properties.
Parts
Name | Description |
---|---|
base |
The component’s base wrapper. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<zn-button>
<zn-button-group>
<zn-chip>
<zn-confirm>
<zn-dropdown>
<zn-empty-state>
<zn-example>
<zn-hover-container>
<zn-icon>
<zn-menu>
<zn-menu-item>
<zn-skeleton>
<zn-tooltip>