Grid Web Component

Overview

Smart.Grid represents a Data Grid component which displays tabular data. It allows you to sort, filter, edit, group the data. With the Smart.Grid, users can Freeze Rows and Columns, Resize Rows and Columns, Select like in Excel, Display Custom Templates in Cells and much more. For more information about the Grid features: https://www.htmlelements.com/grid/.

Getting Started with Grid Web Component

Smart UI for Web Components is distributed as smart-webcomponents NPM package. You can also get the full download from our website with all demos from the Download page.

Setup the Grid

Smart UI for Web Components is distributed as smart-webcomponents NPM package

  1. Download and install the package.

    npm install smart-webcomponents

  2. Once installed, import the Grid module in your application.

    <script type="module" src="node_modules/smart-webcomponents/source/modules/smart.grid.js"></script>

  3. Adding CSS reference

    The smart.default.css CSS file should be referenced using following code.

    <link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />

  4. Add the Grid tag to your Web Page

    <smart-grid id="grid"></smart-grid>

  5. Create the Grid Component

    <script type="module">
    	Smart('#grid', class {
    		get properties() {
    			return {
    				dataSource: new Smart.DataAdapter(
    				{
    					dataSource: [
    						{ "EmployeeID": 1, "FirstName": "Nancy", "LastName": "Davolio", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-05-01 00:00:00", "BirthDate": "1948-12-08 00:00:00", "City": "Seattle", "Address": "507 - 20th Ave. E.Apt. 2A" },
    						{ "EmployeeID": 2, "FirstName": "Andrew", "LastName": "Fuller", "ReportsTo": null, "Country": "USA", "Title": "Vice President, Sales", "HireDate": "1992-08-14 00:00:00", "BirthDate": "1952-02-19 00:00:00", "City": "Tacoma", "Address": "908 W. Capital Way" },
    						{ "EmployeeID": 3, "FirstName": "Janet", "LastName": "Leverling", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-04-01 00:00:00", "BirthDate": "1963-08-30 00:00:00", "City": "Kirkland", "Address": "722 Moss Bay Blvd." },
    						{ "EmployeeID": 4, "FirstName": "Margaret", "LastName": "Peacock", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1993-05-03 00:00:00", "BirthDate": "1937-09-19 00:00:00", "City": "Redmond", "Address": "4110 Old Redmond Rd." },
    						{ "EmployeeID": 5, "FirstName": "Steven", "LastName": "Buchanan", "ReportsTo": 2, "Country": "UK", "Title": "Sales Manager", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1955-03-04 00:00:00", "City": "London", "Address": "14 Garrett Hill" },
    						{ "EmployeeID": 6, "FirstName": "Michael", "LastName": "Suyama", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1963-07-02 00:00:00", "City": "London", "Address": "Coventry House Miner Rd." },
    						{ "EmployeeID": 7, "FirstName": "Robert", "LastName": "King", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-01-02 00:00:00", "BirthDate": "1960-05-29 00:00:00", "City": "London", "Address": "Edgeham Hollow Winchester Way" },
    						{ "EmployeeID": 8, "FirstName": "Laura", "LastName": "Callahan", "ReportsTo": 2, "Country": "USA", "Title": "Inside Sales Coordinator", "HireDate": "1994-03-05 00:00:00", "BirthDate": "1958-01-09 00:00:00", "City": "Seattle", "Address": "4726 - 11th Ave. N.E." },
    						{ "EmployeeID": 9, "FirstName": "Anne", "LastName": "Dodsworth", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-11-15 00:00:00", "BirthDate": "1966-01-27 00:00:00", "City": "London", "Address": "7 Houndstooth Rd." }
    					],
    					dataFields:
    						[
    							'EmployeeID: number',
    							'ReportsTo: number',
    							'FirstName: string',
    							'LastName: string',
    							'Country: string',
    							'City: string',
    							'Address: string',
    							'Title: string',
    							'HireDate: date',
    							'BirthDate: date'
    						]
    				}),
    				sorting: {
    					enabled: true
    				},
    				filtering: {
    					enabled: true
    				},
    				behavior: { columnResizeMode: 'growAndShrink' },
    				columns: [
    					{ label: 'First Name', dataField: 'FirstName', width: 200 },
    					{ label: 'Last Name', dataField: 'LastName', width: 200 },
    					{ label: 'Title', dataField: 'Title', width: 160 },
    					{ label: 'Birth Date', dataField: 'BirthDate', cellsFormat: 'd', width: 120 },
    					{ label: 'Hire Date', dataField: 'HireDate', cellsFormat: 'd', width: 120 },
    					{ label: 'Address', dataField: 'Address', width: 250 },
    					{ label: 'City', dataField: 'City', width: 120 },
    					{ label: 'Country', dataField: 'Country' }			
    				]
    			}
    		}
    	});
    </script>	   
    	
  6. Open the page in your web server.

Another option to create the Grid is by using the traditional Javascript way:
const grid = document.createElement("smart-grid");

grid.id = "myGrid";
grid.editing.enabled = true;
grid.dataSource = new Smart.DataAdapter(
{
	dataSource: [
		{ "EmployeeID": 1, "FirstName": "Nancy", "LastName": "Davolio", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-05-01 00:00:00", "BirthDate": "1948-12-08 00:00:00", "City": "Seattle", "Address": "507 - 20th Ave. E.Apt. 2A" },
		{ "EmployeeID": 2, "FirstName": "Andrew", "LastName": "Fuller", "ReportsTo": null, "Country": "USA", "Title": "Vice President, Sales", "HireDate": "1992-08-14 00:00:00", "BirthDate": "1952-02-19 00:00:00", "City": "Tacoma", "Address": "908 W. Capital Way" },
		{ "EmployeeID": 3, "FirstName": "Janet", "LastName": "Leverling", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-04-01 00:00:00", "BirthDate": "1963-08-30 00:00:00", "City": "Kirkland", "Address": "722 Moss Bay Blvd." },
		{ "EmployeeID": 4, "FirstName": "Margaret", "LastName": "Peacock", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1993-05-03 00:00:00", "BirthDate": "1937-09-19 00:00:00", "City": "Redmond", "Address": "4110 Old Redmond Rd." },
		{ "EmployeeID": 5, "FirstName": "Steven", "LastName": "Buchanan", "ReportsTo": 2, "Country": "UK", "Title": "Sales Manager", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1955-03-04 00:00:00", "City": "London", "Address": "14 Garrett Hill" },
		{ "EmployeeID": 6, "FirstName": "Michael", "LastName": "Suyama", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1963-07-02 00:00:00", "City": "London", "Address": "Coventry House Miner Rd." },
		{ "EmployeeID": 7, "FirstName": "Robert", "LastName": "King", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-01-02 00:00:00", "BirthDate": "1960-05-29 00:00:00", "City": "London", "Address": "Edgeham Hollow Winchester Way" },
		{ "EmployeeID": 8, "FirstName": "Laura", "LastName": "Callahan", "ReportsTo": 2, "Country": "USA", "Title": "Inside Sales Coordinator", "HireDate": "1994-03-05 00:00:00", "BirthDate": "1958-01-09 00:00:00", "City": "Seattle", "Address": "4726 - 11th Ave. N.E." },
		{ "EmployeeID": 9, "FirstName": "Anne", "LastName": "Dodsworth", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-11-15 00:00:00", "BirthDate": "1966-01-27 00:00:00", "City": "London", "Address": "7 Houndstooth Rd." }
	],
	dataFields:
		[
			'EmployeeID: number',
			'ReportsTo: number',
			'FirstName: string',
			'LastName: string',
			'Country: string',
			'City: string',
			'Address: string',
			'Title: string',
			'HireDate: date',
			'BirthDate: date'
		]
});
grid.columns = [
	{ label: 'First Name', dataField: 'FirstName', width: 200 },
	{ label: 'Last Name', dataField: 'LastName', width: 200 },
	{ label: 'Title', dataField: 'Title', width: 160 },
	{ label: 'Birth Date', dataField: 'BirthDate', cellsFormat: 'd', width: 120 },
	{ label: 'Hire Date', dataField: 'HireDate', cellsFormat: 'd', width: 120 },
	{ label: 'Address', dataField: 'Address', width: 250 },
	{ label: 'City', dataField: 'City', width: 120 },
	{ label: 'Country', dataField: 'Country' }
];

document.body.appendChild(grid);
	

Smart framework provides a way to dynamically create a web component on demand from a DIV tag which is used as a host. The following imports the web component's module and creates it on demand, when the document is ready. The #grid is the ID of a DIV tag.

import "../../source/modules/smart.grid.js";

document.readyState === 'complete' ? init() : window.onload = init;

function init() { 
    const grid = new Smart.Grid('#grid', {
        dataSource: new Smart.DataAdapter(
        {
            dataSource: generateData(1000),
            dataFields:
            [
                'id: number',
                'firstName: string',
                'lastName: string',
                'productName: string',
                'available: bool',
                'quantity: number',
                'price: number',
                'total: number'
            ]
        }),
        editing: {
            enabled: true,
            mode: 'cell'
        },
        columns: [
        {
            label: 'First Name', dataField: 'firstName'
        },
        { label: 'Last Name', dataField: 'lastName' },
        { label: 'Product', dataField: 'productName' },
        { label: 'Available', dataField: 'available', template: 'checkBox', editor: 'checkBox' },
        { label: 'Quantity', dataField: 'quantity', editor: 'numberInput' },
        { label: 'Unit Price', dataField: 'price', editor: 'numberInput', cellsFormat: 'c2' }
        ]
    });
}

Example

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Grid Demo</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
	<link rel="stylesheet" type="text/css" href="node_modules/smart-webcomponents/source/styles/smart.default.css" />
</head>
<body class="viewport">
	<smart-grid id="grid"></smart-grid>
    <!-- scripts -->  
	<script type="module" src="node_modules/smart-webcomponents/source/modules/smart.grid.js"></script>
	<script type="module">
	Smart('#grid', class {
		get properties() {
			return {
				dataSource: new Smart.DataAdapter(
				{
					dataSource: [
						{ "EmployeeID": 1, "FirstName": "Nancy", "LastName": "Davolio", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-05-01 00:00:00", "BirthDate": "1948-12-08 00:00:00", "City": "Seattle", "Address": "507 - 20th Ave. E.Apt. 2A" },
						{ "EmployeeID": 2, "FirstName": "Andrew", "LastName": "Fuller", "ReportsTo": null, "Country": "USA", "Title": "Vice President, Sales", "HireDate": "1992-08-14 00:00:00", "BirthDate": "1952-02-19 00:00:00", "City": "Tacoma", "Address": "908 W. Capital Way" },
						{ "EmployeeID": 3, "FirstName": "Janet", "LastName": "Leverling", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1992-04-01 00:00:00", "BirthDate": "1963-08-30 00:00:00", "City": "Kirkland", "Address": "722 Moss Bay Blvd." },
						{ "EmployeeID": 4, "FirstName": "Margaret", "LastName": "Peacock", "ReportsTo": 2, "Country": "USA", "Title": "Sales Representative", "HireDate": "1993-05-03 00:00:00", "BirthDate": "1937-09-19 00:00:00", "City": "Redmond", "Address": "4110 Old Redmond Rd." },
						{ "EmployeeID": 5, "FirstName": "Steven", "LastName": "Buchanan", "ReportsTo": 2, "Country": "UK", "Title": "Sales Manager", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1955-03-04 00:00:00", "City": "London", "Address": "14 Garrett Hill" },
						{ "EmployeeID": 6, "FirstName": "Michael", "LastName": "Suyama", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1993-10-17 00:00:00", "BirthDate": "1963-07-02 00:00:00", "City": "London", "Address": "Coventry House Miner Rd." },
						{ "EmployeeID": 7, "FirstName": "Robert", "LastName": "King", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-01-02 00:00:00", "BirthDate": "1960-05-29 00:00:00", "City": "London", "Address": "Edgeham Hollow Winchester Way" },
						{ "EmployeeID": 8, "FirstName": "Laura", "LastName": "Callahan", "ReportsTo": 2, "Country": "USA", "Title": "Inside Sales Coordinator", "HireDate": "1994-03-05 00:00:00", "BirthDate": "1958-01-09 00:00:00", "City": "Seattle", "Address": "4726 - 11th Ave. N.E." },
						{ "EmployeeID": 9, "FirstName": "Anne", "LastName": "Dodsworth", "ReportsTo": 5, "Country": "UK", "Title": "Sales Representative", "HireDate": "1994-11-15 00:00:00", "BirthDate": "1966-01-27 00:00:00", "City": "London", "Address": "7 Houndstooth Rd." }
					],
					dataFields:
						[
							'EmployeeID: number',
							'ReportsTo: number',
							'FirstName: string',
							'LastName: string',
							'Country: string',
							'City: string',
							'Address: string',
							'Title: string',
							'HireDate: date',
							'BirthDate: date'
						]
				}),
				sorting: {
					enabled: true
				},
				filtering: {
					enabled: true
				},
				behavior: { columnResizeMode: 'growAndShrink' },
				columns: [
					{ label: 'First Name', dataField: 'FirstName', width: 200 },
					{ label: 'Last Name', dataField: 'LastName', width: 200 },
					{ label: 'Title', dataField: 'Title', width: 160 },
					{ label: 'Birth Date', dataField: 'BirthDate', cellsFormat: 'd', width: 120 },
					{ label: 'Hire Date', dataField: 'HireDate', cellsFormat: 'd', width: 120 },
					{ label: 'Address', dataField: 'Address', width: 250 },
					{ label: 'City', dataField: 'City', width: 120 },
					{ label: 'Country', dataField: 'Country' }			
				]
			}
		}
	});
</script>	      	
</body>
</html>

Create, Append, Remove, Get/Set Property, Invoke Method, Bind to Event


Create a new element:
const grid = document.createElement('smart-grid');

Append it to the DOM:
document.body.appendChild(grid);

Remove it from the DOM:
grid.parentNode.removeChild(grid);

Set a property:
grid.propertyName = propertyValue;

Get a property value:
const propertyValue = grid.propertyName;

Invoke a method:
grid.methodName(argument1, argument2);

Add Event Listener:
const eventHandler = (event) => {
   // your code here.
};

grid.addEventListener(eventName, eventHandler);

Remove Event Listener:
grid.removeEventListener(eventName, eventHandler, true);

Using with Typescript

Smart Web Components package includes TypeScript definitions which enables strongly-typed access to the Smart UI Components and their configuration.

Inside the download package, the typescript directory contains .d.ts file for each web component and a smart.elements.d.ts typescript definitions file for all web components. Copy the typescript definitions file to your project and in your TypeScript file add a reference to smart.elements.d.ts

Read more about using Smart UI with Typescript.

Getting Started with Angular Grid Component

Setup Angular Environment

Angular provides the easiest way to set angular CLI projects using Angular CLI tool.

Install the CLI application globally to your machine.

npm install -g @angular/cli

Create a new Application

ng new smart-angular-grid

Navigate to the created project folder

cd smart-angular-grid

Setup the Grid

Smart UI for Angular is distributed as smart-webcomponents-angular NPM package

  1. Download and install the package.
    npm install smart-webcomponents-angular
  2. Adding CSS reference

    The following CSS file is available in ../node_modules/smart-webcomponents-angular/ package folder. This can be referenced in [src/styles.css] using following code.

    @import 'smart-webcomponents-angular/source/styles/smart.default.css';

    Another way to achieve the same is to edit the angular.json file and in the styles add the style.

    "styles": [
    		"node_modules/smart-webcomponents-angular/source/styles/smart.default.css"
    	]
    If you want to use Bootstrap, Fluent or other themes available in the package, you need to add them after 'smart.default.css'.
  3. Example with Angular Standalone Components


    app.component.html

     <smart-grid [dataSource]="dataSource" [columns]="columns" #grid></smart-grid>

    app.component.ts

     import { Component, ViewChild, AfterViewInit, ViewEncapsulation } from '@angular/core';
    import { GridComponent, GridColumn, DataAdapter, Smart } from 'smart-webcomponents-angular/grid';
    
    import { CommonModule } from '@angular/common';
    import { RouterOutlet } from '@angular/router';
    import { GridModule } from 'smart-webcomponents-angular/grid';
    
    @Component({
        selector: 'app-root',
    	standalone: true,
    	imports: [CommonModule, GridModule, RouterOutlet],
        templateUrl: './app.component.html',
        styleUrls: ['app.component.css'],
        encapsulation: ViewEncapsulation.None
    })
    
    export class AppComponent implements AfterViewInit {	
    	@ViewChild("grid", { read: GridComponent, static: false }) grid!: GridComponent;
    
    	dataSource: any[] = [  
    		  { "firstName": "Beate", "lastName": "Wilson", "productName": "Caramel Latte"},   
    		  { "firstName": "Ian", "lastName": "Nodier", "productName": "Caramel Latte"},   
    		  { "firstName": "Petra", "lastName": "Vileid", "productName": "Green Tea"},   
    		  { "firstName": "Mayumi", "lastName": "Ohno", "productName": "Caramel Latte"},   
    		  { "firstName": "Mayumi", "lastName": "Saylor", "productName": "Espresso con Panna"},   
    		  { "firstName": "Regina", "lastName": "Fuller", "productName": "Caffe Americano" },  
    		  { "firstName": "Regina", "lastName": "Burke", "productName": "Caramel Latte"},   
    		  { "firstName": "Andrew", "lastName": "Petersen", "productName": "Caffe Americano"},  
    		  { "firstName": "Martin", "lastName": "Ohno", "productName": "Espresso con Panna"},   
    		  { "firstName": "Beate", "lastName": "Devling", "productName": "Green Tea"},   
    		  { "firstName": "Sven", "lastName": "Devling", "productName": "Espresso Truffle"},  
    		  { "firstName": "Petra", "lastName": "Burke", "productName": "Peppermint Mocha Twist"},  
    		  { "firstName": "Marco", "lastName": "Johnes", "productName": "Caffe Mocha"}  
    	]
    	
    	columns: GridColumn[] = [{
    			label: 'First Name',
    			dataField: 'firstName'
    		},
    		{
    			label: 'Last Name',
    			dataField: 'lastName'
    		},
    		{
    			label: 'Product',
    			dataField: 'productName'
    		}
    	];
    	
    			 
        ngAfterViewInit(): void {
    	
        }
    }
    

  4. Example with Angular NGModule


    app.component.html

     <smart-grid  [dataSource]="dataSource" [columns]="columns" #grid></smart-grid>

    app.component.ts

     import { Component, ViewChild, AfterViewInit, ViewEncapsulation } from '@angular/core';
    import { GridComponent, GridColumn, DataAdapter, Smart } from 'smart-webcomponents-angular/grid';
    
    @Component({
        selector: 'app-root',
        templateUrl: './app.component.html',
        styleUrls: ['app.component.css'],
        encapsulation: ViewEncapsulation.None
    })
    
    export class AppComponent implements AfterViewInit {	
    	@ViewChild("grid", { read: GridComponent, static: false }) grid!: GridComponent;
    
    dataSource: any[] = [  
    		  { "firstName": "Beate", "lastName": "Wilson", "productName": "Caramel Latte"},   
    		  { "firstName": "Ian", "lastName": "Nodier", "productName": "Caramel Latte"},   
    		  { "firstName": "Petra", "lastName": "Vileid", "productName": "Green Tea"},   
    		  { "firstName": "Mayumi", "lastName": "Ohno", "productName": "Caramel Latte"},   
    		  { "firstName": "Mayumi", "lastName": "Saylor", "productName": "Espresso con Panna"},   
    		  { "firstName": "Regina", "lastName": "Fuller", "productName": "Caffe Americano" },  
    		  { "firstName": "Regina", "lastName": "Burke", "productName": "Caramel Latte"},   
    		  { "firstName": "Andrew", "lastName": "Petersen", "productName": "Caffe Americano"},  
    		  { "firstName": "Martin", "lastName": "Ohno", "productName": "Espresso con Panna"},   
    		  { "firstName": "Beate", "lastName": "Devling", "productName": "Green Tea"},   
    		  { "firstName": "Sven", "lastName": "Devling", "productName": "Espresso Truffle"},  
    		  { "firstName": "Petra", "lastName": "Burke", "productName": "Peppermint Mocha Twist"},  
    		  { "firstName": "Marco", "lastName": "Johnes", "productName": "Caffe Mocha"}  
    	]
    	
    	columns: GridColumn[] = [{
    			label: 'First Name',
    			dataField: 'firstName'
    		},
    		{
    			label: 'Last Name',
    			dataField: 'lastName'
    		},
    		{
    			label: 'Product',
    			dataField: 'productName'
    		}
    	];
    	
        ngAfterViewInit(): void {
    		
        }
    }
    

    app.module.ts

     import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { FormsModule } from '@angular/forms';
    
    import { AppComponent } from './app.component';
    import { GridModule } from 'smart-webcomponents-angular/grid';
    
    @NgModule({
        declarations: [AppComponent],
        imports: [BrowserModule, FormsModule, GridModule],
        schemas: [],
        providers: [],
        bootstrap: [AppComponent]
    })
    
    export class AppModule { }


Running the Angular application

After completing the steps required to render a Grid, run the following command to display the output in your web browser

ng serve
and open localhost:4200 in your favorite web browser.

Read more about using Smart UI for Angular: https://www.htmlelements.com/docs/angular-cli/.

Getting Started with React Grid Component

Setup React Environment

The easiest way to start with React is to use NextJS Next.js is a full-stack React framework. It’s versatile and lets you create React apps of any size—from a mostly static blog to a complex dynamic application.

npx create-next-app my-app
cd my-app
npm run dev	
or
yarn create next-app my-app
cd my-app
yarn run dev

Preparation

Setup the Grid

Smart UI for React is distributed as smart-webcomponents-react package

  1. Download and install the package.

    In your React Next.js project, run one of the following commands to install Smart UI Grid for React

    With NPM:

    npm install smart-webcomponents-react
    With Yarn:
    yarn add smart-webcomponents-react

  2. Once installed, import the React Grid Component and CSS files in your application and render it. app.js

    import 'smart-webcomponents-react/source/styles/smart.default.css';
    import { Smart, Grid } from 'smart-webcomponents-react/grid';
    
    export default function Home() {
    
    	const behavior = {
    		columnResizeMode: 'growAndShrink'
    	}
    
    	const appearance = {
    		alternationCount: 2,
    		showRowHeader: true,
    		showRowHeaderSelectIcon: true,
    		showRowHeaderFocusIcon: true
    	}
    
    	const paging = {
    		enabled: true
    	}
    
    	const pager = {
    		visible: true
    	}
    
    	const sorting = {
    		enabled: true
    	}
    
    	const editing = {
    		enabled: true
    	}
    
    	const selection = {
    		enabled: true,
    		allowCellSelection: true,
    		allowRowHeaderSelection: true,
    		allowColumnHeaderSelection: true,
    		mode: 'extended'
    	}
    
    	const dataSource = [  
    	  { "firstName": "Beate", "lastName": "Wilson", "productName": "Caramel Latte"},   
    	  { "firstName": "Ian", "lastName": "Nodier", "productName": "Caramel Latte"},   
    	  { "firstName": "Petra", "lastName": "Vileid", "productName": "Green Tea"},   
    	  { "firstName": "Mayumi", "lastName": "Ohno", "productName": "Caramel Latte"},   
    	  { "firstName": "Mayumi", "lastName": "Saylor", "productName": "Espresso con Panna"},   
    	  { "firstName": "Regina", "lastName": "Fuller", "productName": "Caffe Americano" },  
    	  { "firstName": "Regina", "lastName": "Burke", "productName": "Caramel Latte"},   
    	  { "firstName": "Andrew", "lastName": "Petersen", "productName": "Caffe Americano"},  
    	  { "firstName": "Martin", "lastName": "Ohno", "productName": "Espresso con Panna"},   
    	  { "firstName": "Beate", "lastName": "Devling", "productName": "Green Tea"},   
    	  { "firstName": "Sven", "lastName": "Devling", "productName": "Espresso Truffle"},  
    	  { "firstName": "Petra", "lastName": "Burke", "productName": "Peppermint Mocha Twist"},  
    	  { "firstName": "Marco", "lastName": "Johnes", "productName": "Caffe Mocha"}  
    	]
    	
    	const dataSourceSettings = {
    		dataFields: [
    			'firstName: string',
    			'lastName: string',
    			'productName: string'
    		]
    	}
    
    	const columns = [{
    		label: 'First Name',
    		dataField: 'firstName'
    	},
    	{
    		label: 'Last Name',
    		dataField: 'lastName'
    	},
    	{
    		label: 'Product',
    		dataField: 'productName'
    	}
    	]
    
    	return (
    		<div>
    			<Grid
    				dataSourceSettings={dataSourceSettings}
    				dataSource={dataSource}
    				columns={columns}
    				appearance={appearance}
    				behavior={behavior}
    				selection={selection}
    				paging={paging}
    				pager={pager}
    				sorting={sorting}
    				editing={editing}
    			>
    			</Grid>
    		</div>
    	);
    }
    	

Running the React application

Start the app with
npm run dev
or
yarn run dev
and open localhost:3000 in your favorite web browser to see the output.

Setup with Vite

Vite (French word for "quick", pronounced /vit/, like "veet") is a build tool that aims to provide a faster and leaner development experience for modern web projects
With NPM:
npm create vite@latest
With Yarn:
yarn create vite
Then follow the prompts and choose React as a project.

Navigate to your project's directory. By default it is 'vite-project' and install Smart UI for React

In your Vite project, run one of the following commands to install Smart UI Grid for React

With NPM:

npm install smart-webcomponents-react
With Yarn:
yarn add smart-webcomponents-react

Open src/App.tsx App.tsx

import 'smart-webcomponents-react/source/styles/smart.default.css';
import { Smart, Grid } from 'smart-webcomponents-react/grid';

function App() {

	const behavior = {
		columnResizeMode: 'growAndShrink'
	}

	const appearance = {
		alternationCount: 2,
		showRowHeader: true,
		showRowHeaderSelectIcon: true,
		showRowHeaderFocusIcon: true
	}

	const paging = {
		enabled: true
	}

	const pager = {
		visible: true
	}

	const sorting = {
		enabled: true
	}

	const editing = {
		enabled: true
	}

	const selection = {
		enabled: true,
		allowCellSelection: true,
		allowRowHeaderSelection: true,
		allowColumnHeaderSelection: true,
		mode: 'extended'
	}
	
	const dataSourceSettings = {
		dataFields: [
			'firstName: string',
			'lastName: string',
			'productName: string'
		]
	}
	
	const dataSource = [  
		  { "firstName": "Beate", "lastName": "Wilson", "productName": "Caramel Latte"},   
		  { "firstName": "Ian", "lastName": "Nodier", "productName": "Caramel Latte"},   
		  { "firstName": "Petra", "lastName": "Vileid", "productName": "Green Tea"},   
		  { "firstName": "Mayumi", "lastName": "Ohno", "productName": "Caramel Latte"},   
		  { "firstName": "Mayumi", "lastName": "Saylor", "productName": "Espresso con Panna"},   
		  { "firstName": "Regina", "lastName": "Fuller", "productName": "Caffe Americano" },  
		  { "firstName": "Regina", "lastName": "Burke", "productName": "Caramel Latte"},   
		  { "firstName": "Andrew", "lastName": "Petersen", "productName": "Caffe Americano"},  
		  { "firstName": "Martin", "lastName": "Ohno", "productName": "Espresso con Panna"},   
		  { "firstName": "Beate", "lastName": "Devling", "productName": "Green Tea"},   
		  { "firstName": "Sven", "lastName": "Devling", "productName": "Espresso Truffle"},  
		  { "firstName": "Petra", "lastName": "Burke", "productName": "Peppermint Mocha Twist"},  
		  { "firstName": "Marco", "lastName": "Johnes", "productName": "Caffe Mocha"}  
	]

	const columns = [{
		label: 'First Name',
		dataField: 'firstName'
	},
	{
		label: 'Last Name',
		dataField: 'lastName'
	},
	{
		label: 'Product',
		dataField: 'productName'
	}
	]

	return (
		<div>
			<Grid
				dataSourceSettings={dataSourceSettings}
				dataSource={dataSource}
				columns={columns}
				appearance={appearance}
				behavior={behavior}
				selection={selection}
				paging={paging}
				pager={pager}
				sorting={sorting}
				editing={editing}
			>
			</Grid>
		</div>
	);
}

export default App;
	

Read more about using Smart UI for React: https://www.htmlelements.com/docs/react/.

Getting Started with Vue Grid Component


Setup Vue with Vite

In this section we will introduce how to scaffold a Vue Single Page Application on your local machine. The created project will be using a build setup based on Vite and allow us to use Vue Single-File Components (SFCs). Run the following command in your command line
npm create vue@latest
This command will install and execute create-vue, the official Vue project scaffolding tool. You will be presented with prompts for several optional features such as TypeScript and testing support:
✔ Project name: … 
✔ Add TypeScript? … No / Yes
✔ Add JSX Support? … No / Yes
✔ Add Vue Router for Single Page Application development? … No / Yes
✔ Add Pinia for state management? … No / Yes
✔ Add Vitest for Unit testing? … No / Yes
✔ Add an End-to-End Testing Solution? … No / Cypress / Playwright
✔ Add ESLint for code quality? … No / Yes
✔ Add Prettier for code formatting? … No / Yes

Scaffolding project in ./...
Done.
If you are unsure about an option, simply choose No by hitting enter for now. Once the project is created, follow the instructions to install dependencies and start the dev server:
cd 
npm install
npm install smart-webcomponents
npm run dev
  • Make Vue ignore custom elements defined outside of Vue (e.g., using the Web Components APIs). Otherwise, it will throw a warning about an Unknown custom element, assuming that you forgot to register a global component or misspelled a component name.

    Open src/main.js in your favorite text editor and change its contents to the following:

    main.js

    import { createApp } from 'vue'
    import App from './App.vue'
    
    const app = createApp(App)
    
    app.config.isCustomElement = tag => tag.startsWith('smart-');
    app.mount('#app')
    		
  • Open src/App.vue in your favorite text editor and change its contents to the following:

    App.vue

    <template>
      <div class="vue-root">
        <div class="demo-description">
          The Grid in this demo displays data in a series of rows and columns. This
          is the simplest case when the Grid is bound to a local data source.
        </div>
        <smart-grid id="grid"></smart-grid>
      </div>
    </template>
    
    <script>
    import { onMounted } from "vue";
    import "smart-webcomponents/source/styles/smart.default.css";
    import "smart-webcomponents/source/modules/smart.grid.js";
    
    export default {
      name: "app",
      setup() {
        onMounted(() => {
          window.Smart(
            "#grid",
            class {
              get properties() {
                return {
                  behavior: {
                    columnResizeMode: "growAndShrink"
                  },
                  appearance: {
                    alternationCount: 2,
                    showRowHeader: true,
                    showRowHeaderSelectIcon: true,
                    showRowHeaderFocusIcon: true
                  },
                  paging: {
                    enabled: true
                  },
                  pager: {
                    visible: true
                  },
                  sorting: {
                    enabled: true
                  },
                  editing: {
                    enabled: true
                  },
                  selection: {
                    enabled: true,
                    allowCellSelection: true,
                    allowRowHeaderSelection: true,
                    allowColumnHeaderSelection: true,
                    mode: "extended"
                  },
                  dataSource: [  
    				  { "firstName": "Beate", "lastName": "Wilson", "productName": "Caramel Latte"},   
    				  { "firstName": "Ian", "lastName": "Nodier", "productName": "Caramel Latte"},   
    				  { "firstName": "Petra", "lastName": "Vileid", "productName": "Green Tea"},   
    				  { "firstName": "Mayumi", "lastName": "Ohno", "productName": "Caramel Latte"},   
    				  { "firstName": "Mayumi", "lastName": "Saylor", "productName": "Espresso con Panna"},   
    				  { "firstName": "Regina", "lastName": "Fuller", "productName": "Caffe Americano" },  
    				  { "firstName": "Regina", "lastName": "Burke", "productName": "Caramel Latte"},   
    				  { "firstName": "Andrew", "lastName": "Petersen", "productName": "Caffe Americano"},  
    				  { "firstName": "Martin", "lastName": "Ohno", "productName": "Espresso con Panna"},   
    				  { "firstName": "Beate", "lastName": "Devling", "productName": "Green Tea"},   
    				  { "firstName": "Sven", "lastName": "Devling", "productName": "Espresso Truffle"},  
    				  { "firstName": "Petra", "lastName": "Burke", "productName": "Peppermint Mocha Twist"},  
    				  { "firstName": "Marco", "lastName": "Johnes", "productName": "Caffe Mocha"}  
    				],
                  columns: [
                    {
                      label: "First Name",
                      dataField: "firstName"
                    },
                    {
                      label: "Last Name",
                      dataField: "lastName"
                    },
                    {
                      label: "Product",
                      dataField: "productName"
                    }
                  ]  
                };
              }
            }
          );
        });
      }
    };
    </script>
    
    <style>
    body {
      min-height: 700px;
    }
    
    smart-grid {
      width: 100%;
      height: auto;
    }
    </style>
    		
    We can now use the smart-grid with Vue 3. Data binding and event handlers will just work right out of the box.

Running the Vue application

Start the app with
npm run serve
and open http://localhost:5173/ in your favorite web browser to see the output below:
When you are ready to ship your app to production, run the following:
npm run build
This will create a production-ready build of your app in the project's ./dist directory.

Read more about using Smart UI for Vue: https://www.htmlelements.com/docs/vue/.