Syncfusion JavaScript Library and the SharePoint Framework: A Powerful Combo | 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  (40)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  (118)PDF  (81)Python  (1)React  (100)Streamlit  (1)Succinctly series  (131)Syncfusion  (914)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)
Syncfusion JavaScript Library and the SharePoint Framework :A Powerful Combo

Syncfusion JavaScript Library and the SharePoint Framework: A Powerful Combo

Cloud-based platforms are the present and future of app development. Microsoft SharePoint is one of the cloud-based, collaborative web platforms commonly used to create a firm’s website, manage and transfer files, secure files from being edited by unauthorized users, etc. These features enhance an organization’s productivity, reduce the workforce, improve the workflow, and save time.

In this blog post, we are going to learn step by step how to create a SharePoint Framework (SPFx) application with the Syncfusion JavaScript (Essential JS 2) library in it using VS Code.

Prerequisites

Set up development environment

First, create a client-side web part in the SharePoint Framework. To do so, please follow these steps:

Step 1: Create a new directory called ej2-sharepoint, open the command prompt from that directory, and install the required SharePoint client-side development tools with a global flag.

On Windows:

npm install -g yo gulp @microsoft/generator-sharepoint

On OSX/LINUX:

sudo npm install -g yo gulp @microsoft/generator-sharepoint

Note:The Yeoman SharePoint web part generator @microsoft/generator-sharepoint helps to create a SharePoint client-side project.

Step 2: Then, create a new client-side web part by running the following Yeoman SharePoint Generator command line.

yo @microsoft/sharepoint

Step 3: Set up the following options after the previous command is executed:

  1. Accept the default ej-2-sharepointas your solution name and then select the Enter key.
  2. Choose SharePoint Online only (latest) and select Enter.
  3. ChooseUse the current folder to place the files in the current location and select Enter.
  4. You’ll be asked: Do you want to allow the tenant admin the choice of being able to deploy the solution to all sites immediately without running any feature deployment or adding apps in sites? (Y/N). Choose No.
  5. You’ll be asked: Will the components in the solution require permissions to access web APIs that are unique and not shared with other components in the tenant? (Y/N). Choose No.
  6. Choose WebPartas the client-side component type to be created.

Step 4: Next, it will ask for the specific information about the web part:

  1. Accept the GridComponent as your web part name, and then press the Enter key.
  2. Accept the default GridComponent descriptionas your web part description and select Enter.
  3. Accept the default No javascript frameworkas the framework and select Enter.
    Please refer to the following screenshot for clear information.

Questions asked regarding the WebpartAfter configuring this setup, the Yeoman generator will create the SharePoint client-side web part in the ej2-sharepoint folder and install the required default dependencies.

Configure Syncfusion JavaScript UI control in application

Step 1: Install the @syncfusion/ej2 npm package in the application using the following command line.

npm install @syncfusion/ej2 --save

Step 2: Open the SharePoint application in Visual Studio Code and add the Syncfusion JavaScript Grid control script and styles in the ~/src/webparts/gridComponent/GridComponentWebPart.ts file.

    1. Import the Grid source and add the Syncfusion JavaScript style reference at the top of the file.
    2. Add the DIV element in this.domElement.innerHTML and initialize the Syncfusion JavaScript Grid in the render() method of the GridComponentWebPart class like in the following code example.
....
....


import styles from './GridComponentWebPart.module.scss';
import * as strings from 'GridComponentWebPartStrings';

// import Essential JS 2 Grid
import { Grid } from '@syncfusion/ej2-grids;

// add Syncfusion Essential JS 2 style reference from node_modules
require('../../../node_modules/@syncfusion/ej2/fabric.css');

....
....

export default class GridComponentWebPart extends BaseClientSideWebPart <IGridComponentWebPartProps> {

  public render(): void {
    this.domElement.innerHTML = `
      <div class="${ styles.gridComponent }">
            ....
            ....

        <!--HTML DIV element, which is going to render as Essential JS 2 Grid-->
        <div id="Grid"> </div>
        </div>`;

        // initialize data for grid
let data: Object[] = [
    {
        OrderID: 10248, ShipName: 'Vins et alcools Chevalier', ShipCity: 'Reims'
    },
    {
        OrderID: 10249, ShipName: 'Toms Spezialitäten', ShipCity: 'Münster'
    },
    {
        OrderID: 10250, ShipName: 'Hanari Carnes', ShipCity: 'Rio de Janeiro'
    }]

    // initialize grid control
    let grid: Grid = new Grid({
    dataSource: data});
    // render initialized grid
    grid.appendTo('#Grid');
    }

    ....
    ....

}

Step 3: Run the application using the following command line, and then the Syncfusion JavaScript Grid control will render in your web browser.

gulp serve

Step 4: Click the Add a new web part in column one button like in the following screenshot.
Click the Add a new web part in column one button

Step 5: Select the GridComponent web part as shown in the following screenshot.
Select the GridComponent web part

Finally, the Syncfusion JavaScript Grid control is rendered in your SharePoint Framework client-side web part.

Output showing Syncfusion JavaScript Grid control rendered in SharePoint Framework client-side web partYou can easily access the Essential JS 2 library through the custom SharePoint ButtonComponent.

You can also download this complete project from this GitHub repository.

Conclusion

In this blog, we learned the steps to configure Essential JS 2 in your SharePoint Framework application. For more information, you can also refer to this documentation page. The same procedure can be followed to include any other Essential JS 2 control in an SPFx application.

Syncfusion has over 65 high-performance, lightweight, modular, and responsive UI components in a single package for JavaScript. All these components are available in other frameworks:

If you’re already a Syncfusion user, you can download the product setup from our website. Otherwise, you can download a free, 30-day trial here.

If you wish to send us feedback, please use the comments section below. If you would like to submit any questions, please feel free to contact us through our support forumDirect-Trac, or feedback portal. We are always happy to assist you!

Tags:

Share this post:

Comments (1)

How to connect SharePoint list data, Can you add example as well?

Comments are closed.

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed