Blazor playground

Nova v3.37.0

Preview

Blazor

Datagrid

← nv-datagrid

NvDatagrid Component Guide for Blazor

This guide documents the nv-datagrid usage patterns that are available in Nova and can be used from Blazor applications.

Features

  • Flexible templating for header and cell content
  • Dynamic data rendering from JSON/array data
  • Action bindings for row-level interactions
  • Repeat template support for array values in one cell

Expected Behavior

Data Handling

  • Data provided to the grid is displayed as text without modification.
  • Custom renderers can be used to format data for display.
  • Updates to the dataset should be reflected in the grid.
CaseInput DataDisplay in GridOutput on Selection
Standard row data{ id: 1, name: 'John' }Shows John in Name column{ id: 1, name: 'John' }

Repeat Template

Use repeat-template on nv-datagridcolumn to render each item of an array value inside a single cell.

html<nv-datagrid data-json='[
  {"id":1,"name":"John Doe","roles":[{"id":"1","name":"Admin"},{"id":"2","name":"User"}]},
  {"id":2,"name":"Jane Doe","roles":[{"id":"2","name":"User"}]}
]'>
  <nv-datagridcolumn accessor="name" header="Name">
    <div slot="cell">
      <strong>__name__</strong>
    </div>
  </nv-datagridcolumn>

  <nv-datagridcolumn accessor="roles" header="Role(s)" repeat-template>
    <div slot="cell">
      <nv-badge label="__roles.name__"></nv-badge>
    </div>
  </nv-datagridcolumn>
</nv-datagrid>

Behavior:

  • If the accessor points to an array, each array item is rendered in the same cell.
  • repeat-template controls iteration over array values.

Action Binding

To trigger actions from interactive elements inside a row:

  1. Add data-bind-event to an interactive element.
  2. Use format: eventType:actionName:propNames.
  3. Handle the emitted ActionEvent from the grid.

Example values:

  • click:edit:id
  • click:delete:id
  • click:sendEmail:id,email
html<nv-datagrid data-json="[...]" action="handleGridAction">
  <nv-datagridcolumn accessor="actions">
    <div slot="cell">
      <nv-iconbutton size="xs" name="pencil" data-bind-event="click:edit:id"></nv-iconbutton>
      <nv-iconbutton size="xs" name="trash" data-bind-event="click:delete:id"></nv-iconbutton>
      <nv-iconbutton size="xs" name="mail" data-bind-event="click:sendEmail:id,email"></nv-iconbutton>
    </div>
  </nv-datagridcolumn>
</nv-datagrid>

Notes

  • The grid does not modify original input data.
  • Use custom cell templates for advanced formatting and interactivity.
  • For framework-agnostic API details and live examples, see the nv-datagrid component stories.