Integrating Syncfusion React Components into Meteor | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (174).NET Core  (29).NET MAUI  (207)Angular  (109)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (41)Black Friday Deal  (1)Blazor  (215)BoldSign  (14)DocIO  (24)Essential JS 2  (107)Essential Studio  (200)File Formats  (66)Flutter  (133)JavaScript  (221)Microsoft  (119)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (915)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (51)Windows Forms  (61)WinUI  (68)WPF  (159)Xamarin  (161)XlsIO  (36)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (147)Chart  (131)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (628)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (40)Extensions  (22)File Manager  (7)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (507)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (387)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (592)What's new  (332)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Tile for how to integrate Syncfusion React components into Meteor application blog

How to Integrate Syncfusion React Components into a Meteor Application

Meteor is an open-source JavaScript web framework built using Node.js. As it uses JavaScript in both client and server, it allows you to build real-time applications faster. In addition, Meteor provides various built-in templates to use in your application. Building cross-platform application is the main advantage of the Meteor framework.

Integrating the Syncfusion Essential JS2 React components into Meteor will greatly reduce your development time and provide a rich look for your application. In this blog, I’ll walk you through the step-by-step procedures for configuring Syncfusion React components into Meteor framework.

Prerequisites

To create and run a Meteor app, you need to install Chocolatey and Meteor. Follow these steps:

  • Run the command prompt with administrator privilege
  • Copy the following command and run it in the command prompt. This will install Chocolatey
@”%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe” -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”
  • Now run the following command to install Meteor
choco install meteor

Creating an app in Meteor

Navigate to the project folder in the command prompt and run the following command.

meteor create app

Thus, the default Meteor app with the required HTML, JavaScript, and CSS files will be created. Every new Meteor app includes the Blaze template by default.

Adding React to the Meteor app

As we are going to configure EJ2 React components, we need to add React in Meteor. For this, run the following command in the command prompt.

meteor npm install –save react react-dom

If you wish to remove the default Blaze template and use only React in your project, run the following command. In this blog, we didn’t remove the default template.

meteor remove blaze-html-templates
meteor add static-html

Configuring EJ2 components

You can configure any Syncfusion React component into Meteor. We are going to configure the Data Grid, Charts, and Dropdown List EJ2 React components in this app.

Applying styles for components

Syncfusion EJ2 React components have built-in support for Material, Fabric, Bootstrap, and high contrast themes. Refer our theming documentation to learn more about adding themes for EJ2 React components.

Add Material theme for the components using CSS by referencing the required CDN link in the main.html page.

<head>

<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/material.css" />

</head>

Adding EJ2 Data Grid

Add EJ2 Data Grid to the app by following these steps:

  • Add the div element required to render the grid in the main.html page. In addition, clear the unnecessary HTML elements created by the default template in the main.html page.
<body>

<div id='grid'></div>

</body>
  • Install the grid package using the following command. This will install the React base package and necessary source dependent packages required to render the Data Grid component.
meteor npm install @syncfusion/ej2-react-grids –save
  • To use React in the app, import the following classes in the js file.
import React from '@syncfusion/ej2-react-base/node_modules/react';
import { render } from '@syncfusion/ej2-react-base/node_modules/react-dom';
  • Import the GridComponent and other required classes in the main.js file.
import { GridComponent, Inject, Page, ColumnsDirective, ColumnDirective} from '@syncfusion/ej2-react-grids';
  • Specify the data source and other required properties for the grid.
data = [

{

   OrderID: 10248, CustomerID: 'VINET', EmployeeID: 5, OrderDate: new Date(8364186e5), ShipName: 'Vins et alcools Chevalier', ShipCity: 'Reims', ShipAddress: '59 rue de l Abbaye', ShipRegion: 'CJ', ShipPostalCode: '51100', ShipCountry: 'France', Freight: 32.38, Verified: !0

},

//...

];
 

Meteor.startup(() => {

  render(<GridComponent ref={g => this.grid = g}  width="600" height="450"

    dataSource={data} allowPaging={true}>

    <ColumnsDirective>

    <ColumnDirective field='OrderID' width='100' textAlign="Right"/>

    <ColumnDirective field='CustomerID' width='100'/>

    <ColumnDirective field='EmployeeID' width='100' textAlign="Right"/>

    <ColumnDirective field='Freight' width='100' format="C2" textAlign="Right"/>

    <ColumnDirective field='ShipCountry' width='100'/>

    </ColumnsDirective>

    <Inject services={[Page]} />

    </GridComponent>, document.getElementById('grid')

  );

});

Adding EJ2 Chart

The EJ2 Charts control can be added to the app by following these steps:

  • Add the div element required to render the chart in the main.html page.
<body>

<div id='chart'></div>

</body>
  • After that, install the chart package using the following command
meteor npm install @syncfusion/ej2-react-charts –save
  • Import the ChartComponent and other required classes in the main.js file.
import { ChartComponent, SeriesCollectionDirective, AxesDirective, AxisDirective, SeriesDirective, ColumnSeries, Legend, Category, Tooltip, DataLabel, Zoom, Crosshair, LineSeries, Selection } from'@syncfusion/ej2-react-charts';
  • Specify the data source and other required properties for the charts.
data = [

{

  OrderID: 10248, CustomerID: 'VINET', EmployeeID: 5, OrderDate: new Date(8364186e5), ShipName: 'Vins et alcools Chevalier', ShipCity: 'Reims', ShipAddress: '59 rue de l Abbaye', ShipRegion: 'CJ', ShipPostalCode: '51100', ShipCountry: 'France', Freight: 32.38, Verified: !0

},

//...

];

 

Meteor.startup(() => {

  render(<ChartComponent ref={g => this.chart = g} id='charts' title='Sales

  Analysis' primaryXAxis={ { valueType: 'Category'} } width='550' height='450'

  legendSettings={ { visible: true} } primaryYAxis={ { labelFormat: '${value}K'}

  } tooltip={ { enable: true, shared: false } }>

    <Inject services={[ColumnSeries, Legend, Tooltip, DataLabel, LineSeries,

    Category]}/>

    <SeriesCollectionDirective>

    <SeriesDirective dataSource ={data}  xName='CustomerID' yName='Freight'

    type='Column' marker={ {dataLabel: { visible: true } } } name='Sales'>

    </SeriesDirective>

    </SeriesCollectionDirective>

    </ChartComponent>, document.getElementById('chart')

  );

});

Adding EJ2 Dropdown list

  • Add the div element and CSS required to render the Dropdown List component in the main.html page.
<body>

<div id='dropdown'></div>

</body>
  • Install the dropdown list package using the following command.
meteor npm install @syncfusion/ej2-react-dropdowns –save
  • After that, import the DropDownListComponent class in the main.js file.
import { DropDownListComponent } from '@syncfusion/ej2-react-dropdowns';
  • Specify the data source and other required properties for the Dropdown List component.
dataSource = [

  "France", "Germany", "Brazil", "Belgium", "Switzerland", "Venezuela", "Austria", "Mexico", "USA"

];

 

Meteor.startup(() => {

render(

  <DropDownListComponent id="ddlelement" dataSource={dataSource}

  change={this.onchanged} width ="300" popupHeight="200px" popupWidth="250px"

  placeholder="select a country" />, document.getElementById('dropdown')

);

});

Filtering data

In this example, we have filtered the data of a chart and data grid using the ShipCountry field while selecting options in a drop-down list. For this, we have subscribed to the change event of the drop-down list. After generating the new data, we assigned it and refreshed the Data Grid and Charts controls.

onchanged = function(args){

  var newData = [];

  for(var i=0; i<data.length; i++){

  if(args.itemData.value == data[i]["ShipCountry"])

    newData.push(data[i]);

  }

  grid.dataSource = newData;

  grid.refresh();

  chart.series[0].dataSource = newData;

  chart.refresh();

}

Running the app

The created app can be run using the following command.

Meteor

The app will be running at the address by default. However, the running port can be changed by following this command.

meteor run –port [PORT]

This is the output of the sample.

Output of EJ2 React components in Meteor application
Filtered for Germany

You can get the complete sample from this GitHub location. We hope you are now comfortable with configuring the Syncfusion React components into Meteor framework. If you have any questions or need any clarification, please let us know in the comments section. You can also contact us through our support forum or Direct-Trac. We are always happy to assist you!

If you liked this post, we think you’ll also enjoy the following:

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed