Typescript Web Components

Typescript Web Components



Typescript support comes with the next version of Smart Web Components. We are super excited about this. We will expose Interfaces, Types and Classes for all our stuff. Each API member will include descriptions, which will help you to use our product and see the intellisense suggestions by Visual Studio Code, Visual Studio and other IDEs with such support.

Grid Typescript Init

This sample shows how to create basic Grid using TypeScript

import {Grid, GridColumn, DataAdapter, Smart} from "../typescript/smart.elements";  
 window.onload = function () {  
   const grid: Grid = <Grid>document.createElement("smart-grid");  
   grid.columns = <GridColumn[]>[  
     {label: "First Name", dataField: "firstName"},  
     {label: "Last Name", dataField: "lastName"}  
   ]  
   const adapter = new Smart.DataAdapter( {  
     dataSource: [  
       {firstName: "Name", lastName: "Last Name"},  
       {firstName: "Name 2", lastName: "Last Name 2"},  
       {firstName: "Name 3", lastName: "Last Name 3"},  
       {firstName: "Name 4", lastName: "Last Name 4"},  
       {firstName: "Name 5", lastName: "Last Name 5"}  
     ],  
     dataFields: [  
       'firstName: string',  
       'lastName: string'  
     ]  
   }) as DataAdapter;  
   grid.dataSource = adapter;  
   document.body.appendChild<Grid>(grid);  
 }  

This entry was posted in Smart Grid, Web Components and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply