The SpreadJS Designer Component is a separate deployment add-on package that gives JavaScript developers the ability to embed an interactive UI similar to Excel, making it easier for the users to interact with the spreadsheets.
This highly customizable, flexible add-on component includes Angular, React, and Vue wrappers, making it possible to add it to all these JavaScript frameworks easily.
In the first section of this blog, you will learn how you can add the Designer Component to your AngularJS, React, and Vue web applications. We will also show how you can make various customizations to this component with minimal effort on your part.
Let's get started!
Using the Designer Component in different JavaScript Frameworks
In the first section of this blog, you will learn how you can add the Designer Component to your AngularJS, React, and Vue web applications. Next, we will show how you can make various customizations to this component with minimal effort on your part
AngularJS
After having created your application, follow the next steps:
- Import the following SpreadJS modules into your project
- Import the designer and resources module in the app.module.ts file
- Import the designer CSS files in app.component.css file
- Add the designer tag and an event listener to the designer initialized event in the app.component.html file
- Pass the props parameters to configure the designer
Also, initialize the designer to access the SpreadJS instance
- Save and run the application
In no time, you will have embedded in your Angular Application a ready-to-use Designer Component.
React
To add the Designer Component to your React Application, follow the below steps:
- Import the following SpreadJS modules into your project
- Import the required modules in the App.js file
- Render the Designer Component using the following code:
- Save and Run the application
Vue
To add the Designer Component to your Vue Application do as follows:
- Import the following SpreadJS modules into your project
- Import the required modules
- Add the designer tag as below
- Configure and initialize the Designer in you App.vue file
- Save and Run the application
Customizations
This section will show you how you can customize the SpreadJS Designer component according to your user needs.
Below there the sections and features of the Designer Component that can be customized:
- Ribbon, context menu, file menu, and side panels can be deleted but not modified or added
- Buttons, tabs, context menu options, dialog boxes, etc., can be customized
- The response or interaction of each element can be customized by setting commandMap to register the command
Download this sample to follow the various customizations that we will describe below.
Note: You can look at this blog for further instructions on how to customize the component.
Enable or Disable Ribbon Elements
Below, we show how you can disable three buttons on the INSERT menu.
Note: Be aware if you wish to enable buttons that need a selection of data to be functional, for example: insertChart.
- Access the default configuration and identify the command with the button you wish to disable or enable. In our case, we have disabled the PivotTable, Picture, and Camera on the INSERT menu
- Apply getCommand method on the right command to identify its state expression
- Set the above command to commandMap in your project and disable the respective state expression by setting the enableContext option
- Initialize the designer instance by passing "config" parameter for customizable configuration
You will notice that the mentioned buttons are now disabled.
Bind File Import Events
Designer Component provides event binding methods such as bind, unbind, and unbindAll. These methods help to add or remove events in the Designer Component. For example, you can use these functions during file import operations.
The events used in our sample are FileLoading and FileLoaded. FileLoading event displays the number of worksheets if the imported file format is Excel. In contrast, the FileLoaded event displays a message when the file import is completed.
Customize Designer Localization
Get the original designer resource object using the getResources method
Modify the content of the resource object
Set the modified resource object using the setResources method
There were just a few cases on how you can customize the SpreadJS Designer Component.
Want to know more?
Contact us to learn more at us.sales@grapecity.com and visit the SpreadJS page.
If you have any questions or insights you like to share, you are welcome to post a comment below!