` for features pages */ .template-features { --inpage-nav-content-width: 100%; --inpage-nav-sidebar-width: 0px; --feature-content-max-width: 100%; --feature-content-padding-bottom: calc(var(--inner-y-padding) / 2); --section-margin: 2rem; } .template-features .zg-layout-section { background:linear-gradient(rgba(248,248,248,1), #fff 70%); } .template-features .zg-layout-main { padding-right:0; padding-left:0; } .template-features [data-zg-inpage-nav] { display:none; } /* INTRO SECTION */ [data-feature-intro="box"] { margin-top:calc(var(--inner-y-padding) * -1); background:#fff; box-sizing:border-box; } [data-feature-intro="wrap"] { padding:var(--inner-y-padding) var(--layout-main-padding-right) var(--inner-y-padding) var(--layout-main-padding-left); width:100%; box-sizing:border-box; } [data-feature-intro="wrap"] > :first-child { margin-top:0 !important; } [data-feature-intro="wrap"] > :last-child { margin-bottom:0 !important; } /* REGULAR DEMO SECTION */ [data-feature-section="box"] { background:none; border-top:2px solid var(--border-color-light); box-sizing:border-box; } [data-feature-section="box"] + [data-feature-section="box"] { margin-top:-1px; } [data-feature-section="content"] { padding:var(--inner-y-padding) var(--layout-main-padding-left) var(--feature-content-padding-bottom); width:100%; max-width:var(--feature-content-max-width); box-sizing:border-box; } [data-feature-section="content"] > :first-child { margin-top:0 !important; } [data-feature-section="content"] > :last-child { margin-bottom:0 !important; } [data-feature-section="demo"] { border:1px solid var(--border-color-light); box-sizing:border-box; } [data-feature-section="demo-wrap"] { padding:var(--feature-demo-padding-top) var(--layout-main-padding-left) var(--inner-y-padding); box-sizing:border-box; } /* CARD LINKS */ #zg-feature-cards { display: flex; flex-direction: row; flex-wrap: wrap; align-items: stretch; height: fit-content; } #zg-feature-cards div { position: relative; display: inline-block; flex-basis: 10%; border: 1px solid #e8e8e8; border-radius: 5px; background-color: #fff; padding: 0 1rem; box-shadow: 0 4px 15px rgb(0 0 0 / 10%); margin: 1rem; flex-grow: 1; flex-shrink: 1; font-weight: 500;} /* RELATED RESOURCES SECTION */ [data-feature-related="wrap"] { padding:var(--inner-y-padding) var(--layout-main-padding-right) var(--inner-y-padding) var(--layout-main-padding-left); width:100%; max-width:var(--feature-content-max-width); box-sizing:border-box; } [data-feature-related="wrap"] > :first-child { margin-top:0 !important; } [data-feature-related="wrap"] > :last-child { margin-bottom:0 !important; } /* API GRID TABS --------------------------- */ /* Toggle api elements tables */ .api-element--section .grid-type--container section { display:none; } .api-element--section input[type="radio"]:first-child:checked ~ .grid-type--container section:first-child, .api-element--section input[type="radio"]:last-of-type:checked ~ .grid-type--container section:last-of-type { display: initial; } .grid-type--tabs { margin-top:25px; margin-bottom:27px; height:28px; border-bottom:1px solid #cdd6de; } [data-docs-api~="main"] .grid-type--tabs { margin-bottom:30px; } .grid-type--tabs input[tab] { display: none; } .grid-type--tabs input[tab] + label { border-bottom: 3px solid transparent; float: left; font-size: .9rem; font-weight: 500; margin-right: 16px; opacity: .4; padding: 0 5px 3px; position: relative; user-select: none; } .grid-type--tabs label + input[tab] + label:before { content: ''; border-left: 1px solid #bbb; display: block; height: 11px; position: absolute; left: -7px; top: 50%; transform: translateY(-50%); } .grid-type--tabs input[tab]:checked+label { opacity: 1; border-bottom-color: var(--color-tertiary-1); } /* API STYLING --------------------------- */ .zg-collapse-all { margin-top:45px; min-height:35px; display:flex; align-items:center; } .zg-collapse-all [data-zg-button] { margin-left:auto; padding-right:10px; padding-left:10px; min-width:110px; opacity:0; animation:FADE .7s forwards; } .card-header { position:relative; padding-right:75px; display:flex; align-items:center; overflow:hidden; } .card-header.collapsed { margin-bottom:-1px !important; border-radius:var(--border-radius); } .card-header > * { margin-bottom:0 !important; } .card-header .h4 { color:var(--color-primary-1); } .zg-collapse-all-item { position:absolute; top:0; right:0; width:58px; height:100%; display:flex; align-items:center; justify-content:center; cursor:pointer; background:#ececec; border-left:1px solid #d8dee4; border-radius:0 var(--border-radius) var(--border-radius) 0; } .zg-collapse-all-item > * { pointer-events:none; } .zg-collapse-all-item svg { --icon-fill:var(--color-grayscale-3); width:30px; height:30px; } .zg-collapse-all-item [icon-plus] { display:none; } /* Individual Collapsed */ .collapsed .zg-collapse-all-item, .zg-collapse-all-item.collapsed { background:var(--color-primary-5); border-left-color:transparent; } .collapsed .zg-collapse-all-item svg, .zg-collapse-all-item.collapsed svg { --icon-fill:#fff; } .collapsed .zg-collapse-all-item [icon-minus], .zg-collapse-all-item.collapsed [icon-minus] { display:none; } .collapsed .zg-collapse-all-item [icon-plus], .zg-collapse-all-item.collapsed [icon-plus] { display:block; } .card-body { position:relative; height:auto; font-size:.875rem; } .collapsed .card-body, .card-header.collapsed + .card-body { padding:0; height:0; overflow:hidden; } .card-body .h5 { margin:0 0 3px; font-size:.9375rem; } .card-body p { margin-bottom:17px; } .card-body ul[data-count="small"] { columns: 1; } .card-body ul[data-count="medium"] { columns: 2; } .card-body ul[data-count="large"] { columns: 3; } .card-body .view-demo { display:flex; align-items:center; } .card-body .view-demo svg { --icon-fill:var(--color-secondary-1); width:15px; height:15px; margin-left:8px; } [data-js-type] { font-size:12px; padding: 2px 7px; background-color: #cdd6de; border-radius: 15px; margin-left: 30px;} [data-js-type="Boolean"] { background-color: #9fa8da; } [data-js-type="Number"] { background-color: #90caf9; } [data-js-type="String"] { background-color: #80cbc4; } [data-js-type="Object"] { background-color: #ffab91; } [data-js-type="function"] { background-color: #ffcc80; } /* .table--outer-wrapper { width:100%; overflow:hidden; } .table--inner-wrapper { max-width:100%; overflow:auto; } */ .api-grid { background:#fff; box-shadow:var(--box-shadow); border:1px solid #e3e3e3; border-collapse:collapse; width:100%; } /* Caption styling */ .api-grid caption { background:var(--color-primary-1); text-align:left; padding:10px 1rem; color:#fff; font-weight: 600; font-size:22px;} /* Header styling */ .api-grid thead { color:var(--color-alert-light); border-bottom: 1px solid #eee; } .api-grid th[table-col] { position:-webkit-sticky; position:sticky; top:calc(var(--header-height) - 1px); padding-top:5px; padding-bottom:5px; height:35px; color:#212121; font-weight:600; background:#fbfbfb; border-width:0 0 1px; border-bottom-color:var(--border-color-lighter); user-select:none; } /* Zebra striping */ .api-grid tbody tr:nth-child(even) { background:rgba(166, 213, 250, 0.2);; } /* Column styling */ .api-grid [table-col] { text-align:left; word-break:break-word; padding:.7rem .5rem; user-select:all; font-size:.9rem; line-height:1.3; border-width:0 1px 1px; } .api-grid [table-col="name"] { font-weight:var(--font-weight-500); } .api-grid [table-col="name"] a { border-bottom:none; } /* Override code block styling in these grids */ .api-grid [table-col="description"] code { color:var(--color-greyscale-1); background-color:transparent; border-width:0; padding:2px; } .api-grid [table-col="description"] { cursor: pointer; } .api-grid.expanded [table-col="description"] { transition: width .22s ease-in; width: 500px; } .api-grid [table-col="description"] .wrapper { max-height:100px; overflow:hidden;} .api-grid [table-col="demo"] a, .api-grid [table-col="cssref"] a { border-bottom:none; } .api-grid [table-col="demo"] svg, .api-grid [table-col="cssref"] svg { height:14px; width:14px; --icon-fill: var(--icon-fill_alt); } .api-grid [table-col="demo"] svg, .api-grid [table-col="cssref"] svg { stroke:var(--icon-fill_alt); fill:var(--icon-fill_alt); } .api-grid [table-col="demo"]:hover svg, .api-grid [table-col="cssref"]:hover svg { stroke:var(--icon-fill_alt); fill:var(--icon-fill_alt); } [table-type="relationship"] [table-col="component"] [data-icon-link], [table-type="relationship"] [table-col="ancestor"] [data-icon-link] { height: 14px } [table-type="relationship"] [table-col="component"] .zg-anchor:hover, [table-type="relationship"] [table-col="ancestor"] .zg-anchor:hover { text-decoration: underline; } /* Disabled demos (href not available) */ .api-grid [table-col="demo"] svg[disabled], .api-grid [table-col="cssref"] svg[disabled] { cursor:not-allowed; stroke:var(--color-grayscale-3); fill:var(--color-grayscale-3); } .small--api-grid { max-width: 500px;} .api-grid tbody tr.highlight td { background:#fff59d; } @media screen and (min-width: 1200px) { .api-grid [table-col]:first-child { padding-left:1rem; } .api-grid [table-col]:last-child { padding-right:1rem; } .api-grid [table-col="demo"], .api-grid [table-col="cssref"] { padding-right:0 !important; padding-left:0 !important; text-align:center; padding-top:23px; } } @media screen and (max-width: 1200px) { .api-grid, .api-grid tbody, .api-grid tr, .api-grid th, .api-grid td { border: 0; display: grid; text-align: left !important; } .api-grid thead { display: none; } .api-grid tr { background-color: #d7ebf5 !important; border-block-end: 2px solid var(--border-color-lighter); } .api-grid [table-col] { background-color: unset; padding: .4rem .65rem; } .api-grid td:before { content: attr(data-label); font-weight: bold; } .api-grid td:not([table-col="cssref"], [table-col="demo"]) { background-color: #fff !important; } .api-grid [table-col="action"]:before { content: 'Action: '; } .api-grid [table-col="type"]:before { content: 'Type: '; } .api-grid [table-col="success"]:before { content: 'Sucess: '; } .api-grid [table-col="error"]:before { content: 'Error: '; } .api-grid [table-col="returns"]:before { content: 'Returns: '; } .api-grid [table-col="cssref"]:before { content: 'Reference: '; } .api-grid [table-col="default"]:before { content: 'Default: '; } .api-grid [table-col="demo"]:before { content: 'Demo: '; } .api-grid [table-col="demo"]:before { content: 'Demo: '; } .api-grid [table-col="description"]:before { content: 'Description: '; } .api-grid [table-col="name"] { padding-block-start: .6rem; } .api-grid [table-col="name"]:before { content: 'Name: '; } .api-grid [table-col="name"] a { font-size: 106%; } .api-grid [table-col="component"]:before { content: 'Component: '; } .api-grid [table-col="relationship"]:before { content: 'Relationship: '; } .api-grid [table-col="ancestor"]:before { content: 'Ancestor: '; } .api-grid [table-col="description"] { border-block-end: 1px solid var(--border-color-lighter); padding-block-end: .6rem; } .api-grid [table-col="demo"] a, .api-grid [table-col="cssref"] a { display: inline-block; transform: translateY(3px); } .api-grid .zg-anchor.active-load, .api-grid .zg-anchor:hover { display: inline-block; margin: 0; padding: 0; transform: unset; } .api-grid .zg-anchor:hover [data-icon-link] { display: none; } } @media screen and (max-width: 524.95px) { .api-grid tr { grid-template-columns: repeat(3, 1fr); } .card-body ul[data-count="large"] { columns: 1; } } @media screen and (min-width: 525px) and (max-width: 1200px) { .api-grid tr { grid-template-columns: repeat(4, 1fr); } } @media screen and (min-width: 380px) and (max-width: 1200px) { .api-grid tr { background-color: #d7ebf5 !important; border-block-end: 2px solid var(--border-color-lighter); display: grid; } .api-grid td:not([table-col="cssref"], [table-col="demo"]) { grid-column: 1 / -1; } } /* MEDIA QUERIES (MIN) --------------------------- */ /* TABLET: PORTRAIT+ */ @media screen and (min-width:1300px) { /* Docs Intro Sections */ [zing-intro-link-group] { display: grid; grid-template-columns: repeat(3, 1fr); column-gap: 1.5rem; row-gap: 1.5rem; } [zing-intro-link-group].double { display: grid; grid-template-columns: repeat(2, 1fr); column-gap: 1.5rem; } } /* DESKTOP+ */ @media screen and (min-width:1300px) { /* 'FEATURES' CUSTOM PAGE LAYOUT ---------------------------------- */ .template-features { --feature-content-max-width: 930px; } } /* WHEN THE PAGE CONTENT MAXES AND STARTS TO CENTER */ @media screen and (min-width:1500px) { /* FEATURES PAGES: NEXT / PREV */ .template-features [data-zg-next-prev="box"] { width:calc(var(--feature-content-max-width) - ( var(--layout-main-padding-left) * 2 )); } } /* MAX VIEWPORT */ @media screen and (min-width:1664px) { .template-features [data-type~="docs-default"] .inner { margin-right:0; width:auto; } [html-mobile-menu-open] .template-features [data-type~="docs-default"] .inner { margin-left:0; } } /* WHEN WE GO TO 2 COLUMNS ON FEATURES PAGES */ @media screen and (min-width:1825px) { .template-features { --feature-demo-padding-top: var(--inner-y-padding); } /* 'FEATURES' CUSTOM PAGE LAYOUT ---------------------------------- */ [data-feature-section="box"] { display:grid; grid-template-columns:minmax(1px, var(--feature-content-max-width)) 1fr; } [data-feature-section="box"].last { border-bottom:2px solid var(--border-color-light); } [data-feature-section="content"] { position:relative; } [data-feature-section="content"] .to-top { position:absolute; bottom:5px; right:5px; margin:0 !important; } [data-feature-intro="box"] + * .to-top { display:none; } [data-feature-section="content"] .to-top span { padding:0 5px; } [data-feature-section="content"] .to-top em { display:none; } [data-feature-section="demo"] { background:linear-gradient(90deg,rgba(255,255,255,1), rgba(255,255,255,0)); border-width:0 0 1px 1px; } [data-feature-section="box"].last [data-feature-section="demo"] { border-width:0 0 0 1px; } } /* MEDIA QUERIES (MAX) --------------------------- */ /* WHEN WE GO TO 2 COLUMNS ON FEATURES PAGES */ @media screen and (max-width:1824px) { .template-features { --feature-demo-padding-top: 0; } [data-feature-section="demo"] { padding-top:0; border-width:0; } } @media screen and (max-width:1295px) { [zing-intro-link-group] zing-intro-link-card:not(:first-child) { margin-top: 1.5rem; } [zing-intro-link-group] { display: flex; flex-direction: column; } } /* ITERATOR SECTION ---------------------------------- */ [data-zg-iterator-content] { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 5rem; text-transform: capitalize; } [data-zg-iterator-content] [no-transform] { text-transform: none; } [data-zg-iterator-content][padded] { padding: 0 64px; } [data-zg-iterator-content] div:first-child { text-align: left; } [data-zg-iterator-content] div:nth-child(2) { text-align: center; } [data-zg-iterator-content] div:last-child { text-align: right; } @media screen and (max-width:767px) { [data-zg-iterator-content] { display: block; } [data-zg-iterator-content] > div:first-child, [data-zg-iterator-content] > div:last-child { text-align: center; } [data-zg-iterator-content] p { margin: 0; } }

Using JavaScript with ZingGrid

As custom elements, ZingGrid tags have access to the standard JavaScript DOM API.

Element Manipulation

After the grid renders, you are able to query select any Light DOM elements and manipulate them. For example, you can update the caption either by changing the attribute value or the <zg-caption> text directly (see below).

<zing-grid id="myZingGrid" caption="Original Caption"></zing-grid>

<script>
  let zgRef = document.querySelector('#myZingGrid');
  let zgCaption = zgRef.querySelector('zg-caption');
  zgCaption.textContent = 'New Caption';
</script>

If you inspect the demo after changing the caption, you'll notice that the caption attribute on ZingGrid was not updated! As we saw in the Attribute Versus Element guide, ZingGrid has unidirectional sync controlled by the attribute, not the corresponding element. So when updating grid elements, it is recommended to update the attribute (see below), which will sync the matching elements.

<zing-grid id="myZingGrid" caption="Original Caption"></zing-grid>

<script>
  let zgRef = document.querySelector('#myZingGrid');
  zgRef.setAttribute('caption', 'New Caption');
</script>
Top

Native Events

ZingGrid exposes many lifecycle events for you to hook into to customize the grid's behavior. Simply add an event listener to control when to execute your custom code.

For example, the grid:ready event is emitted from the <zing-grid> element when it has finished rendering. Add a listener for it and then execute your code.

record:click Grid

The record:click event is emitted when you click on a body <zg-row>. Test it out in the accompanying demo:

<zing-grid
    id="myGrid" 
    data='[{"firstName":"John", "lastName":"Doe"}, {"firstName":"Jane", "lastName":"Doe"}]'
    caption="Click a row to animate the grid"
  >
  </zing-grid>

  <style>
    @keyframes BOUNCE {
      0%, 100% { transform: translateY(0); }
      50% { transform: translateY(-15px); }
    }
    .animate { animation:BOUNCE .5s; }
  </style>

  <script>
    let zgRef = document.querySelector('#myGrid');
    zgRef.addEventListener('record:click', e => {
      zgRef.classList.add('animate');
    });
  </script>
https://app.zingsoft.com/demos/embed/3RVBEFZE
https://app.zingsoft.com/demos/embed/3RVBEFZE
Top

Custom Events

Bind normal event actions, like so:

<zing-grid data='[{"firstName":"John", "lastName":"Doe"}, {"firstName":"Jane", "lastName":"Doe"}]'>
  <zg-caption onclick="handleClick">Click me</zg-caption>
</zing-grid>

<script>
  function handleClick() {
    alert('Caption clicked!');
  }
</script>

Or bind a modern event listener to separate concerns, like so:

<zing-grid id="myZingGrid" data='[{"firstName":"John", "lastName":"Doe"}, {"firstName":"Jane", "lastName":"Doe"}]'>
  <zg-caption id="myCaption">Click me</zg-caption>
</zing-grid>

<script>
  document.querySelector('#myCaption').addEventListener('click', handleClick);

  function handleClick() {
    alert('Caption clicked!');
  }
</script>
Top

Using ZingGrid With Frameworks

ZingGrid can be used with modern frameworks like React, Vue, and Angular, just like native HTML or other Custom Elements. When using these, take note that they are abstracting and virtualizing the DOM, which can introduce considerations not normally encountered with static HTML implementations.

Please view the integration examples for your specific framework for further details and examples:

If you do not see your framework listed above, please let us know.

Top

[guides: using JavaScript]