BY Ajay Singh19 Sep 2022 Edit
WebAtoms - DataGrid

What is DataGrid Control?

A DataGrid is a class component that extends from the TableRepeater control. A TableRepeater control simply represents the table structure that consists of the table, the header, the body, and the footer. This control also extends from AtomRepeater control.

A DataGrid user interface control helps display the information or data in a grid-like format of rows and columns. In this UI control, you can define customized columns and sort orders for each header. A headerSort property can be used to specify the order in which columns load. We can add the desc order query by using headerSortDescending.

What are the properties of DataGrid control?

orderBy - This is the two-way data binding, to load any specific column in default order, we can set this property before the top node.

selectedItems - Gets the DataGrid's selected items as a collection.

items- Gets the items displayed in the DataGrid.

columns- This property is bound to the array which defines the header, headerSort, headerSortDescending, and labelPath as properties for const variable of type IDataGridColumn.

SelectAllColumn - Checkboxes are added to all columns in the control with this property.

One great benefit is that AtomRepeater properties can also be used here. Other than columns, all properties are bindable properties.

Code snippet of DataGrid Control?

       items={Bind.oneWay(() => this.ViewModel.ProductList)}

How to define the columns?

In the code, we define the array of objects of type IDataGridColumn.

  const columns: IDataGridColumn[] = [
                header: "Title",
                labelPath: (item: IProduct) => item.title
                header: "Brand",
                labelPath: (item: IProduct) => item.brand
                header: "Category",
                labelPath: (item: IProduct) => item.category


We have set the columns property of DataGrid to this const property which is the type of IDataGridColumn. It provides us to select all columns if we mention the SelectAllColumn value inside the array. Adding a checkbox to each row in the "DataGrid" will let you perform single or multiple operations.

Header means the heading of the column labelPath is used to display the text headerSortDescending will sort the column in descending order.

Advantages of DataGrid Control?

  • In addition to auto-generating columns, it also provides sorting properties (by default ASC) and allows setting the order in desc.
  • It is easier to understand this control due to its less code approach, and the order definition and column definition are separated.
  • The separation of concerns approach makes maintenance easy. -We can use the repeater control properties since this control extends TableRepeater.
  • Since this control is very lightweight and is based on the latest technology, it doesn't require the installation of any additional npm packages.
BY Ajay Singh
Developer Guides
Web Atoms Updates

17 Mar 2021
Simmi Kava
commented this post.
Simmi Kava
liked this post.
Show more
javascript (56)
developer (25)
javascriptdeveloper (16)
Xamarin.Forms (16)
Html (14)
typescript (12)
webatoms (12)
xamarin (11)
coding (10)
web-atoms (10)
arrays (9)
android (8)
javascript-developer (8)
csharp (7)
dotnet (7)
css (6)
update (6)
dotnet-standard (5)
function (5)
iOS (5)
methods (4)

Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository