30
loading...
This website collects cookies to deliver better user experience
From the Settings option, open the Developer console as shown in the following screenshot.
Then, in the Developer Console window, select File> New> Lightning Component.
Now, provide a name (I’m using the name EJ2SalesComponent) and a description for the component. Then, select the following options:
<ltng:require scripts="{!$Resource.ej2}" styles="{!$Resource.ej2Css}"
afterScriptsLoaded="{!c.doInit}"/>
// EJ2SalesComponent.cmp
<aura:component implements="flexipage:availableForRecordHome" access="public">
<ltng:require scripts="{!$Resource.ej2}" styles="{!$Resource.ej2Css}"
afterScriptsLoaded="{!c.doInit}"/>
<p>EJ2 Components</p>
<div>
<hr/>
<h1>Grid Component</h1>
<div id='grid'></div>
<h1>Button Component</h1>
<button id=’btn’>
</button>
</div>
</aura:component>
// EJ2SalesComponentController.js
({
doInit : function(component, event, helper) {
// dataSoruce for Grid
var data = [{ OrderID: 10248, CustomerID: 'VINET', Freight: 32.38, OrderDate: new Date(8364186e5) },
{ OrderID: 10249, CustomerID: 'TOMSP', Freight: 11.61, OrderDate: new Date(836505e6) },
{ OrderID: 10250, CustomerID: 'HANAR', Freight: 65.83, OrderDate: new Date(8367642e5) },
{ OrderID: 10251, CustomerID: 'VICTE', Freight: 41.34, OrderDate: new Date(8368506e5) },
{ OrderID: 10252, CustomerID: 'SUPRD', Freight: 51.3, OrderDate: new Date(8367642e5) },
{ OrderID: 10253, CustomerID: 'HANAR', Freight: 58.17, OrderDate: new Date(836937e6) },
{ OrderID: 10254, CustomerID: 'CHOPS', Freight: 22.98, OrderDate: new Date(8370234e5) },
{ OrderID: 10255, CustomerID: 'RICSU', Freight: 148.33, OrderDate: new Date(8371098e5) },
{ OrderID: 10256, CustomerID: 'WELLI', Freight: 13.97, OrderDate: new Date(837369e6) }];
//control intialization
var Button = new ej.buttons.Button({content:'snm',cssClass:'e-primary'},'#snm');
var Grid = new ej.grids.Grid({dataSource: data},'#grid')
}
})
<aura:application >
<c:EJ2SalesComponent />
</aura:application>
Then, the preview of the component will be loaded in the browser like in the following screenshot. Here, we can verify the component structure and alignment.
To use the custom Lightning UI component as a tab or within a page, refer to the instructions provided in the Add Lightning Components as Custom Tabs in a Lightning App documentation.