ZingGrid Analytics Table

The same analytics data from the sortable table demo, but rendered with ZingGrid — a web component that provides sorting, filtering, search, pagination, and more via declarative HTML attributes.

Vanilla JS (300+ lines)

// Sort, filter, paginate, render,
// column toggles, CSV export,
// event listeners, state management,
// debounce, ARIA attributes...
// ~300 lines of JavaScript

ZingGrid (~10 lines of HTML)

<zing-grid
  src="sample-pageviews.json"
  pager page-size="25"
  sort filter search
  caption="Analytics Pageviews">
</zing-grid>
ZingGrid renders semantic <table> markup with ARIA roles by default. Unlike many grid libraries that use <div>-based layouts, ZingGrid outputs real <table>, <tr>, and <td> elements with role="grid", role="row", and role="gridcell" attributes — accessible out of the box.

Live Demo

Custom Cell Renderers for CWV Thresholds

ZingGrid's renderer attribute calls a JavaScript function for each cell. The functions below apply Core Web Vitals threshold coloring (green/amber/red):

// CWV thresholds
const LCP_GOOD = 2500, LCP_POOR = 4000;
const CLS_GOOD = 0.1,  CLS_POOR = 0.25;
const INP_GOOD = 200,  INP_POOR = 500;

function cwvClass(value, good, poor) {
    if (value <= good) return 'cwv-good';
    if (value <= poor) return 'cwv-needs-improvement';
    return 'cwv-poor';
}

function renderLCP(value) {
    return `<span class="${cwvClass(value, LCP_GOOD, LCP_POOR)}"
             style="padding:2px 8px;border-radius:3px;">
              ${Math.round(value)}
            </span>`;
}

Comparison: When to Use What

Feature Vanilla JS ZingGrid
DependenciesNone~200 KB (CDN)
Code Required300+ lines JS~10 lines HTML
Sort / Filter / SearchManual implementationDeclarative attributes
PaginationManual implementationpager attribute
REST API IntegrationManual fetch()src attribute
Custom StylingFull controlRenderers + CSS
AccessibilityManual ARIABuilt-in ARIA
Learning ValueHigh (understand internals)High (understand components)