Select theme:

Material 3

DataGrid (Angular)link

This guide demonstrates how to use the DataGrid component.

Quick videolink

DataGrid Propertieslink

NameTypeDefaultDescription
Namestring'grid' + index suffixUnique name of the DataGrid.
DataarraynullDataGrid data.
CountintegernullDataGrid number of all records.
PageSizeinteger10DataGrid number of records per page.
AllowDeletebooleanfalseIs records delete allowed.
AllowAddbooleanfalseIs adding of new records allowed.
AllowPagingbooleanfalseIs paging allowed.
AllowSortingbooleanfalseIs sorting allowed.
AllowMultiSortingbooleanfalseIs multi sorting allowed.
AllowFilteringbooleanfalseIs filtering allowed.
AllowScrollingbooleanfalseIs scrolling allowed.
Visibleboolean/expressiontrueIs DataGrid visible.
EmptyTextstringNo records to display.DataGrid text on no records.
Columnsarray of GridColumnemptyDataGrid columns.
TemplatestringnullDataGrid row details template.
ApplyFilterTextstringApplyDataGrid date column filter apply button text.
ClearFilterTextstringClearDataGrid date column filter clear button text.
EqualsTextstringEqualsDataGrid date column filter Equals function text.
NotEqualsTextstringNot equalsDataGrid date column filter NotEqualsText function text.
LessThanTextstringLess thanDataGrid date column filter LessThanText function text.
LessThanOrEqualsTextstringLess than or equalsDataGrid date column filter LessThanOrEqualsText function text.
GreaterThanTextstringGreater thanDataGrid date column filter clear GreaterThanText text.
GreaterThanOrEqualsTextstringGreater than or equalsDataGrid date column filter GreaterThanOrEqualsText function text.
EndsWithTextstringEnds withDataGrid date column filter EndsWithText function text.
ContainsTextstringContainsDataGrid date column filter ContainsText function text.
StartsWithTextstringStarts withDataGrid date column filter StartsWithText function text.

image

DataGrid Eventslink

NameTypeDescription
RowSelecteventRow select event of the DataGrid. Fired when row is selected. Row data as event arguments.
RowDoubleClickeventRow double click event of the DataGrid. Fired when row is double clicked. Row data as event arguments.
RowExpandeventRow expand event of the DataGrid. Fired when row is expanded. Row data as event arguments.
RowCollapseeventRow collapse event of the DataGrid. Fired when row is collapsed. Row data as event arguments.
AddeventAdd event of the DataGrid. Fired when Add button is pressed. No event arguments.
CreateeventFired when the user saves a new record during inline editing. The event argument is the row data.
UpdateeventFired when the user saves an existing record during inline editing. The event argument is the row data.
DeleteeventDelete event of the DataGrid. Fired when Delete button is pressed. Row data as event argument.
LoadDataeventLoad data event of the DataGrid raised on page, sort and filter with info about the current page, page size, sorted columns and filter expressions in OData v4 format

image

GridColumn Propertieslink

NameTypeDefaultDescription
TypestringstringGridColumn type. string, integer, number or boolean.
FormatstringnullGridColumn format. int32, int64, float, double, byte, binary, base64, date, date-time, date-time-offset or password.
PropertystringnullGridColumn property name.
SortPropertystringnullGridColumn sort property name. If not set Property will be used for sorting.
FilterPropertystringnullGridColumn filter property name. If not set Property will be used for filtering.
TitlestringnullGridColumn title.
TemplatestringnullGridColumn template.
FooterTemplatestringnullGridColumn footer template.
WidthnumbernullGridColumn width in pixels.
SortablebooleantrueIs sorting allowed for this column.
FilterablebooleantrueIs filtering allowed for this column.

Customizing the column appearancelink

By default the DataGrid component displays the value of the Property in a column. Use the Template property to customize the appearance. The whole data item is available as data in the expression.

Template examples:

  • <strong>${data.FirstName}</strong> - display the FirstName property in a <strong></strong> element.
  • Full Name: ${data.FirstName} ${data.LastName} - display two data item properties in the column.

Footer templatelink

  • <b>TOTAL: ${totalUnitPrice | currency}</b> - display the total UnitPrice property in a <b></b> element.

You can apply calculations on current page data or all items using the following expression: ${result.value.map(p=>p.UnitPrice).reduce((a, b) => a + b)}. If you want the calculation to be applied on all items you can request them separately using for example $select parameter:

image image image

Angular declarationlink

  <rz-grid #grid0 addText="Add" [allowFiltering]="true" [allowPaging]="true" [allowSorting]="true" [count]="getProductsCount" [data]="getProductsResult" emptyText="No records to display." [pageSize]="10" (loadData)="grid0LoadData($event)">
    <rz-grid-column property="ProductID" title="Product ID" type="integer">
    </rz-grid-column>
    <rz-grid-column property="ProductName" title="Product Name" type="string">
    </rz-grid-column>
    <rz-grid-column property="QuantityPerUnit" title="Quantity Per Unit" type="string">
    </rz-grid-column>
    <rz-grid-column format="decimal" property="UnitPrice" title="Unit Price" type="number">
      <ng-template let-data gridColumnTemplate>
      {{data?.UnitPrice | currency}}
      </ng-template>
      <ng-template gridColumnFooterTemplate>
      <b>TOTAL: {{totalUnitPrice | currency}}</b>
      </ng-template>
    </rz-grid-column>
    <rz-grid-column format="int16" property="UnitsInStock" title="Units In Stock" type="integer">
      <ng-template let-data gridColumnTemplate>
      {{data?.UnitsInStock}}
      </ng-template>
      <ng-template gridColumnFooterTemplate>
      <b>TOTAL: {{totalUnitsInStock}}</b>
      </ng-template>
    </rz-grid-column>
    <rz-grid-column format="int16" property="UnitsOnOrder" title="Units On Order" type="integer">
    </rz-grid-column>
    <rz-grid-column format="int16" property="ReorderLevel" title="Reorder Level" type="integer">
    </rz-grid-column>
    <rz-grid-column property="Discontinued" title="Discontinued" type="boolean">
    </rz-grid-column>
  </rz-grid>

In-memory and server-side operationslink

DataGrid component can perform sorting, paging and filtering both in-memory and server-side.

  • For in-memory operations enable respective feature, add load event for the Page, call your service and set data property to returned value. image image

  • For server-side operations enable respective feature, add load event for the Page, call your service and set data and count properties to returned values, add loadData event handler, call your service again with provide information in the event argument and set again data and count properties to returned values. If you use New Data Dialog, Radzen will setup everything automatically. image image image

Sorting and Filtering by lookup fieldslink

DataGrid component can sort and filter by lookup fields by defining SortProperty and FilterProperty for desired column. When generating pages from OData V4, Microsoft SQL Server, MySQL, Oracle or PostgreSQL, Radzen will set automatically SortProperty and FilterProperty for all lookup columns based on data-source relations.

image image

Example request

http://services.radzen.com/odata/OrderDetails?$filter=contains(Product/ProductName,%20%27Ch%27)&$top=10&$skip=0&$orderby=Product/ProductName%20desc&$expand=Order,Product&$count=true
© 2016-2025 Radzen Ltd. All Rights Reserved.
Designed and developed with ❤️ in Radzen Blazor Studio.

Select theme:

Material 3