Interface for a class Grid
EmitType<
PageEventArgs
|GroupEventArgs
|FilterEventArgs
|SearchEventArgs
|SortEventArgs
|AddEventArgs
|SaveEventArgs
|EditEventArgs
|DeleteEventArgs
|ActionEventArgs
>
Triggers when Grid actions such as sorting, filtering, paging, grouping etc., starts.
import { Grid, Page, PageEventArgs } from '@syncfusion/ej2-grids';
import { orderDataSource } from './data-source';
Grid.Inject(Page);
let grid: Grid = new Grid({
dataSource: orderDataSource,
allowPaging: true,
// For Paging action
actionBegin: (args: PageEventArgs) => {
console.log(args.requestType);
}
});
grid.appendTo("#Grid");
EmitType<
PageEventArgs
|GroupEventArgs
|FilterEventArgs
|SearchEventArgs
|SortEventArgs
|AddEventArgs
|SaveEventArgs
|EditEventArgs
|DeleteEventArgs
|ActionEventArgs
>
Triggers when Grid actions such as sorting, filtering, paging, grouping etc. are completed.
Triggers when any Grid action failed to achieve the desired results.
EmitType<BatchAddArgs>
Triggers when records are added in batch mode.
EmitType<BatchCancelArgs>
Triggers when cancel the batch edit changes batch mode.
EmitType<BatchDeleteArgs>
Triggers when records are deleted in batch mode.
EmitType<BeforeAutoFillEventArgs>
Triggers before Grid autoFill action.
Triggers before records are added in batch mode.
EmitType<BeforeBatchDeleteArgs>
Triggers before records are deleted in batch mode.
Triggers before records are saved in batch mode.
EmitType<BeforeCopyEventArgs>
Triggers before Grid copy action.
Triggers before data is bound to Grid.
EmitType<Object>
Triggers before Grid data is exported to Excel file.
EmitType<AdaptiveDialogEventArgs>
Triggers before adaptive filter and sort dialogs open.
EmitType<ColumnChooserEventArgs>
Triggers before the columnChooser open.
EmitType<BeforePasteEventArgs>
Triggers before Grid paste action.
EmitType<Object>
Triggers before Grid data is exported to PDF document.
Triggers before the print action starts.
Triggers before the record is to be edit.
EmitType<CellDeselectEventArgs>
Triggers when a particular selected cell is deselected.
EmitType<CellDeselectEventArgs>
Triggers before the selected cell is deselecting.
Triggers when the cell is being edited.
Triggers when cell is saved.
Triggers when cell is saved.
Triggers after a cell is selected.
EmitType<CellSelectingEventArgs>
Triggers before any cell selection occurs.
EmitType<CheckBoxChangeEventArgs>
Triggers when the check box state change in checkbox column.
EmitType<ColumnDataStateChangeEventArgs>
Triggers when the grid actions such as Sorting, Paging, Grouping etc., are done to get column dataSource
.
In this event,the current view column data and total record count should be assigned to the column dataSource
based
on the action performed.
EmitType<ColumnDeselectEventArgs>
Triggers when a selected column is deselected.
EmitType<ColumnDeselectEventArgs>
Triggers before deselecting the selected column.
Triggers when column header element is dragged (moved) continuously.
Triggers when column header element drag (move) starts.
Triggers when a column header element is dropped on the target column.
EmitType<MenuEventArgs>
Triggers when click on column menu.
EmitType<ColumnMenuOpenEventArgs>
Triggers before column menu opens.
EmitType<ColumnSelectEventArgs>
Triggers after a column is selected.
EmitType<ColumnSelectingEventArgs>
Triggers before column selection occurs.
EmitType<CommandClickEventArgs>
Triggers when command button is clicked.
EmitType<MenuEventArgs>
Triggers when click on context menu.
EmitType<BeforeOpenCloseMenuEventArgs>
Triggers before context menu opens.
EmitType<Object>
Triggers when the component is created.
EmitType<Object>
Triggers when data source is populated in the Grid.
EmitType<DataSourceChangedEventArgs>
Triggers when the grid data is added, deleted and updated. Invoke the done method from the argument to start render after edit operation.
EmitType<DataStateChangeEventArgs>
Triggers when the grid actions such as Sorting, Paging, Grouping etc., are done.
In this event,the current view data and total record count should be assigned to the dataSource
based on the action performed.
EmitType<Object>
Triggers when the component is destroyed.
EmitType<DetailDataBoundEventArgs>
Triggers after detail row expands.
This event triggers at initial expand.
EmitType<AggregateQueryCellInfoEventArgs>
Triggers before exporting aggregate cell to Excel document. You can also customize the PDF cells.
EmitType<ExcelExportCompleteArgs>
Triggers after Grid data is exported to Excel file.
EmitType<ExcelHeaderQueryCellInfoEventArgs>
Triggers before exporting each header cell to Excel file. You can also customize the Excel cells.
EmitType<ExcelQueryCellInfoEventArgs>
Triggers before exporting each cell to Excel file. You can also customize the Excel cells.
EmitType<ExportDetailDataBoundEventArgs>
Triggers before exporting each detail Grid to PDF document.
EmitType<ExportGroupCaptionEventArgs>
Triggers before exporting each caption row to PDF/Excel/CSV document. You can also customize the export caption row values.
EmitType<HeaderCellInfoEventArgs>
Triggered for stacked header.
EmitType<KeyboardEventArgs>
Triggers when any keyboard keys are pressed inside the grid.
Triggers when collapse the caption row in lazy load grouping.
Triggers when expand the caption row in lazy load grouping.
EmitType<Object>
This event allows customization of Grid properties before rendering.
EmitType<AggregateQueryCellInfoEventArgs>
Triggers before exporting aggregate cell to PDF document. You can also customize the PDF cells.
EmitType<PdfExportCompleteArgs>
Triggers after Grid data is exported to PDF document.
EmitType<PdfHeaderQueryCellInfoEventArgs>
Triggers before exporting each header cell to PDF document. You can also customize the PDF cells.
EmitType<PdfQueryCellInfoEventArgs>
Triggers before exporting each cell to PDF document. You can also customize the PDF cells.
Triggers after print action is completed.
EmitType<QueryCellInfoEventArgs>
Triggered every time a request is made to access cell information, element, or data. This will be triggered before the cell element is appended to the Grid element.
EmitType<RecordClickEventArgs>
Triggers when record is clicked.
EmitType<RecordDoubleClickEventArgs>
Triggers when record is double clicked.
Triggers when column resize starts.
Triggers when column resize ends.
Triggers on column resizing.
EmitType<RowDataBoundEventArgs>
Triggered every time a request is made to access row information, element, or data. This will be triggered before the row element is appended to the Grid element.
EmitType<RowDeselectEventArgs>
Triggers when a selected row is deselected.
EmitType<RowDeselectEventArgs>
Triggers before deselecting the selected row.
Triggers when row elements are dragged (moved) continuously.
Triggers when row element’s drag(move) starts.
Triggers when row element’s before drag(move).
Triggers when row elements are dropped on the target row.
Triggers after a row is selected.
EmitType<RowSelectingEventArgs>
Triggers before row selection occurs.
EmitType<ClickEventArgs>
Triggers when toolbar item is clicked.
Configures the Grid aggregate rows.
<div id='Grid'></grid>
import { Grid, Aggregate } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Aggregate);
let grid: Grid = new Grid({
dataSource: data,
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120 },
{ field: 'Freight', headerText: 'Freight', width: 150, textAlign: 'Right', format:'C2' },
],
aggregates: [{
columns: [{type: 'Sum',field: 'Freight',format: 'C2',footerTemplate: 'Sum: ${Sum}'}]
}]
});
grid.appendTo('#Grid');
Check the
Aggregates
for its configuration.
boolean
If allowExcelExport
set to true, then it will allow the user to export grid to Excel file.
Check the
ExcelExport
to configure exporting document.
<div id='Grid'></grid>
import { Grid, Toolbar, ExcelExport } from '@syncfusion/ej2-grids';
import { orderDetails } from './data-source';
Grid.Inject(Toolbar, ExcelExport);
let grid: Grid = new Grid(
{
dataSource: orderDetails,
allowExcelExport: true,
toolbar: ['ExcelExport'],
});
grid.appendTo('#Grid');
boolean
If allowFiltering
set to true the filter bar will be displayed.
If set to false the filter bar will not be displayed.
Filter bar allows the user to filter grid records with required criteria.
Check the
Filtering
to customize its default behavior.
<div id='Grid'></grid>
import { Grid, Filter } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Filter);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowFiltering: true,
});
grid.appendTo('#Grid');
boolean
If allowGrouping
set to true, then it will allow the user to dynamically group or ungroup columns.
Grouping can be done by drag and drop columns from column header to group drop area.
Check the
Grouping
to customize its default behavior.
<div id='Grid'></grid>
import { Grid, Group } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Group);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowGrouping: true,
});
grid.appendTo('#Grid');
boolean
Enables or disables the key board interaction of Grid.
boolean
If allowMultiSorting
set to true, then it will allow the user to sort multiple column in the grid.
allowSorting
should be true.
<div id='Grid'></grid>
import { Grid, Sort } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Sort);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowSorting: true,
allowMultiSorting: true,
});
grid.appendTo('#Grid');
boolean
If allowPaging
is set to true, the pager renders at the footer of the Grid. It is used to handle page navigation in the Grid.
Check the
Paging
to configure the grid pager.
boolean
If allowPdfExport
set to true, then it will allow the user to export grid to Pdf file.
Check the
Pdfexport
to configure the exporting document.
<div id='Grid'></grid>
import { Grid, Toolbar, PdfExport } from '@syncfusion/ej2-grids';
import { orderDetails } from './data-source';
Grid.Inject(Toolbar, PdfExport);
let grid: Grid = new Grid(
{
dataSource: orderDetails,
allowPdfExport: true,
toolbar: ['PdfExport'],
});
grid.appendTo('#Grid');
boolean
If allowReordering
is set to true, Grid columns can be reordered.
Reordering can be done by drag and drop of a particular column from one index to another index.
If Grid is rendered with stacked headers, reordering is allowed only at the same level as the column headers.
<div id='Grid'></grid>
import { Grid, Reorder } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Reorder);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowReordering: true,
});
grid.appendTo('#Grid');
boolean
If allowResizing
is set to true, Grid columns can be resized.
<div id='Grid'></grid>
import { Grid, Resize } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Resize );
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowResizing: true,
});
grid.appendTo('#Grid');
boolean
If allowRowDragAndDrop
is set to true, you can drag and drop grid rows at another grid.
<div id='Grid'></grid>
import { Grid, RowDD } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(RowDD );
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowRowDragAndDrop: true,
});
grid.appendTo('#Grid');
boolean
If allowSelection
is set to true, it allows selection of (highlight row) Grid records by clicking it.
<div id='Grid'></grid>
import { Grid, Selection } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Selection );
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowSelection: true,
});
grid.appendTo('#Grid');
boolean
If allowSorting
is set to true, it allows sorting of grid records when column header is clicked.
Check the
Sorting
to customize its default behavior.
<div id='Grid'></grid>
import { Grid, Sort } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Sort);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowSorting: true,
});
grid.appendTo('#Grid');
boolean
If allowTextWrap
set to true,
then text content will wrap to the next line when its text content exceeds the width of the Column Cells.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowTextWrap: true,
});
grid.appendTo('#Grid');
Defines Grid options to render child Grid.
It requires the queryString
for parent
and child relationship.
Check the
Child Grid
for its configuration.
string
Defines the mode of clip. The available modes are,
Clip
: Truncates the cell content when it overflows its area.
Ellipsis
: Displays ellipsis when the cell content overflows its area.
EllipsisWithTooltip
: Displays ellipsis when the cell content overflows its area,
also it will display the tooltip while hover on ellipsis is applied.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
clipMode: 'Ellipsis',
});
grid.appendTo('#Grid');
Configures the column chooser in the Grid.
string[]
| ColumnMenuItemModel[]
columnMenuItems
defines both built-in and custom column menu items.
The available built-in items are,
AutoFitAll
- Auto fit the size of all columns.AutoFit
- Auto fit the current column.Group
- Group by current column.Ungroup
- Ungroup by current column.SortAscending
- Sort the current column in ascending order.SortDescending
- Sort the current column in descending order.Filter
- Filter options will show based on filterSettings property like checkbox filter, excel filter, menu filter. string
columnQueryMode
provides options to retrive data from the datasource.Their types are
All
: It Retrives whole datasource.Schema
: Retrives data for all the defined columns in grid from the datasource.ExcludeHidden
: Retrives data only for visible columns of grid from the dataSource. Column[]
| string[]
| ColumnModel[]
Defines the schema of dataSource.
If the columns
declaration is empty or undefined then the columns
are automatically generated from data source.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
columns: [
{ field: 'CategoryName', headerText: 'Category Name', width: 150 },
{ field: 'ProductName', headerText: 'Product Name', width: 150 },
],
});
grid.appendTo('#Grid');
string[]
| ContextMenuItemModel[]
contextMenuItems
defines both built-in and custom context menu items.
The available built-in items are,
AutoFitAll
- Auto fit the size of all columns.AutoFit
- Auto fit the current column.Group
- Group by current column.Ungroup
- Ungroup by current column.Edit
- Edit the current record.Delete
- Delete the current record.Save
- Save the edited record.Cancel
- Cancel the edited state.Copy
- Copy the selected records.PdfExport
- Export the grid as Pdf format.ExcelExport
- Export the grid as Excel format.CsvExport
- Export the grid as CSV format.SortAscending
- Sort the current column in ascending order.SortDescending
- Sort the current column in descending order.FirstPage
- Go to the first page.PrevPage
- Go to the previous page.LastPage
- Go to the last page.NextPage
- Go to the next page. string
Defines the own class for the grid element.
ActionArgs
Gets or sets the current action details.
Object
| DataManager
| DataResult
It is used to render grid table rows.
If the dataSource
is an array of JavaScript objects,
then Grid will create instance of DataManager
from this dataSource
.
If the dataSource
is an existing DataManager
,
the Grid will not initialize a new one.
Check the available
Adaptors
to customize the data operation.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
});
grid.appendTo('#Grid');
string
The detail template allows you to show or hide additional information about a particular row.
It accepts either the template string or the HTML element ID.
Configures the edit settings.
<div id='Grid'></grid>
import { Grid, Toolbar, Edit } from '@syncfusion/ej2-grids';
import { data } from './data-source';
Grid.Inject(Toolbar,Edit);
let grid: Grid = new Grid({
dataSource: data,
toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'],
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal' },
});
grid.appendTo('#Grid');
string
Defines the version for Grid persistence.
boolean
If enableAdaptiveUI
set to true the grid filter, sort, and edit dialogs render adaptively.
boolean
If enableAltRow
is set to true, the grid will render with e-altrow
CSS class to the alternative tr elements.
Check the
AltRow
to customize the styles of alternative rows.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableAltRow: false,
});
grid.appendTo('#Grid');
boolean
If enableAutoFill
is set to true, then the auto fill icon will displayed on cell selection for copy cells.
It requires the selection mode
to be Cell and cellSelectionMode
to be Box
.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableAutoFill: true,
selectionSettings:{mode:'Cell',cellSelectionMode:'Box'}
});
grid.appendTo('#Grid');
boolean
If enableColumnVirtualization
set to true, then the Grid will render only the columns visible within the view-port
and load subsequent columns on horizontal scrolling. This helps to load large dataset of columns in Grid.
<div id='Grid'></grid>
import { Grid, VirtualScroll} from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(VirtualScroll);
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableVirtualization: true,
enableColumnVirtualization: true,
height: 300,
});
grid.appendTo('#Grid');
boolean
If enableHeaderFocus
set to true, then header element will be focused when focus moves to grid.
boolean
If enableHover
is set to true, the row hover is enabled in the Grid.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableHover: true,
});
grid.appendTo('#Grid');
boolean
If enableImmutableMode
is set to true, the grid will reuse old rows if it exists in the new result instead of
full refresh while performing the grid actions.
boolean
If enableInfiniteScrolling
set to true, then the data will be loaded in Grid when the scrollbar reaches the end.
This helps to load large dataset in Grid.
<div id='Grid'></grid>
import { Grid, InfiniteScroll} from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(InfiniteScroll);
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableInfiniteScrolling: true,
height: 300,
});
grid.appendTo('#Grid');
boolean
Enable or disable persisting component’s state between page reloads.
boolean
Enable or disable rendering component in right to left direction.
boolean
If ‘enableStickyHeader’ set to true, then the user can able to make the column headers visible when the document is scrolled.
boolean
Specifies the shimmer effect for Grid virtual and infinite scrolling.
boolean
If enableVirtualization
set to true, then the Grid will render only the rows visible within the view-port
and load subsequent rows on vertical scrolling. This helps to load large dataset in Grid.
<div id='Grid'></grid>
import { Grid, VirtualScroll } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(VirtualScroll);
let grid: Grid = new Grid(
{
dataSource: categoryData,
enableVirtualization: true,
height: 300
});
grid.appendTo('#Grid');
Configures the filter settings of the Grid.
<div id='Grid'></grid>
import { Grid, Filter } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Filter);
let grid: Grid = new Grid(
{
dataSource: categoryData,
allowFiltering: true,
filterSettings: { type:'Menu'},
});
grid.appendTo('#Grid');
number
Gets or sets the number of frozen columns.
<div id='Grid'></grid>
import { Grid, Freeze } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Freeze);
let grid: Grid = new Grid(
{
dataSource: categoryData,
frozenColumns: 2,
});
grid.appendTo('#Grid');
number
Gets or sets the number of frozen rows.
<div id='Grid'></grid>
import { Grid, Freeze } from '@syncfusion/ej2-grids';
import { categoryData } from './data-source';
Grid.Inject(Freeze);
let grid: Grid = new Grid(
{
dataSource: categoryData,
frozenRows: 2,
});
grid.appendTo('#Grid');
string
Defines the mode of grid lines. The available modes are,
Both
: Displays both horizontal and vertical grid lines.None
: No grid lines are displayed.Horizontal
: Displays the horizontal grid lines only.Vertical
: Displays the vertical grid lines only.Default
: Displays grid lines based on the theme.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
gridLines: 'Both',
});
grid.appendTo('#Grid');
Configures the group settings.
<div id='Grid'></grid>
import { Grid, Group } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Group);
let grid: Grid = new Grid({
dataSource: data,
allowGrouping: true,
groupSettings: { columns: ['Freight'] },
columns: [
{ field: 'OrderID', headerText: 'Order ID', textAlign: 'Right', width: 120 },
{ field: 'Freight', headerText: 'Freight', width: 150, textAlign: 'Right', format:'C2' },
],
});
grid.appendTo('#Grid');
string
| number
Defines the scrollable height of the grid content.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
height: '400',
});
grid.appendTo('#Grid');
string
Defines the hierarchy grid print modes. The available modes are
Expanded
- Prints the master grid with expanded child grids.All
- Prints the master grid with all the child grids.None
- Prints the master grid alone.Configures the infinite scroll settings.
<div id='Grid'></grid>
import { Grid, InfiniteScroll } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(InfiniteScroll);
let grid: Grid = new Grid({
dataSource: data,
height: 300,
pageSettings: { pageSize: 50 },
enableInfiniteScrolling: true,
infiniteScrollSettings: { enableCache: true, maxBlocks: 3, initialBlocks: 3 },
});
grid.appendTo('#Grid');
Configures the Loading Indicator of the Grid.
string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Configures the pager in the Grid.
<div id='Grid'></grid>
import { Grid, Page } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Page);
let grid: Grid = new Grid({
dataSource: data,
allowPaging:true,
pageSettings: { currentPage: 1, pageSize: 12, pageCount: 8, pageSizes: true },
});
grid.appendTo('#Grid');
string
It used to render pager template
ParentDetails
Gets the parent Grid details.
string
Defines the print modes. The available print modes are
AllPages
: Prints all pages of the Grid.CurrentPage
: Prints the current page of the Grid.
<div id='Grid'></grid>
import { Grid, Page, Toolbar } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Page,Toolbar);
let grid: Grid = new Grid({
dataSource: data,
toolbar: ['Print'],
printMode: 'CurrentPage',
allowPaging: true,
});
grid.appendTo('#Grid');
Query
Defines the external Query
that will be executed along with data processing.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { DataManager, Query, ODataAdaptor } from '@syncfusion/ej2-data';
let data: DataManager = new DataManager({
url: 'https://js.syncfusion.com/demos/ejServices/Wcf/Northwind.svc/Orders/?$top=7',
adaptor: new ODataAdaptor
});
let grid: Grid = new Grid({
dataSource: data,
query: new Query().addParams('ej2grid', 'true'),
});
grid.appendTo('#Grid');
string
Defines the relationship between parent and child datasource. It acts as the foreign key for parent datasource.
Defines the resizing behavior of the Grid.
Configures the row drop settings.
number
Defines the height of Grid rows.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
rowHeight: 20,
});
grid.appendTo('#Grid');
string
Defines the grid row elements rendering direction. The available directions are,
Horizontal
: Renders the grid row elements in the horizontal directionVertical
: Renders the grid row elements in the vertical direction string
The row template that renders customized rows from the given template. By default, Grid renders a table row for every data source item.
- It accepts either template string or HTML element ID.
- The row template must be a table row. Check the
Row Template
customization.
Configures the search behavior in the Grid.
<div id='Grid'></grid>
import { Grid, Search, Toolbar } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Search,Toolbar);
let grid: Grid = new Grid({
dataSource: data,
toolbar: ['Search'],
searchSettings: { fields: ['CustomerID'], key: 'ha' },
columns: [
{ field: 'CustomerID', headerText: 'Customer ID', width: 150 },
{ field: 'Freight', headerText: 'Freight', width: 150, textAlign: 'Right', format:'C2' },
]
});
grid.appendTo('#Grid');
number
The selectedRowIndex
allows you to select a row at initial rendering.
You can also get the currently selected row index.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
selectedRowIndex: 5,
});
grid.appendTo('#Grid');
Configures the selection settings.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
selectionSettings: { mode: 'Cell', cellSelectionMode: 'Box', type: 'Multiple' },
});
grid.appendTo('#Grid');
boolean
If showColumnChooser
is set to true, it allows you to dynamically show or hide columns.
Check the
ColumnChooser
for its configuration.
<div id='Grid'></grid>
import { Grid, ColumnChooser, Toolbar } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(ColumnChooser, Toolbar);
let grid: Grid = new Grid({
dataSource: data,
toolbar: ['ColumnChooser'],
showColumnChooser: true,
});
grid.appendTo('#Grid');
boolean
If showColumnMenu
set to true, then it will enable the column menu options in each columns.
Check the
Column menu
for its configuration.
<div id='Grid'></grid>
import { Grid, ColumnMenu } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(ColumnMenu);
let grid: Grid = new Grid({
dataSource: data,
showColumnMenu: true,
});
grid.appendTo('#Grid');
Configures the sort settings.
<div id='Grid'></grid>
import { Grid, Sort } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Sort);
let grid: Grid = new Grid({
dataSource: data,
allowSorting: true,
sortSettings: { columns: [{ field: 'OrderID', direction: 'Ascending' }] },
columns: [
{ field: 'CustomerID', headerText: 'Customer ID', width: 150 },
{ field: 'Freight', headerText: 'Freight', width: 150, textAlign: 'Right', format:'C2' },
]
});
grid.appendTo('#Grid');
Configures the text wrap in the Grid.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
allowTextWrap: true,
textWrapSettings: { wrapMode: 'Both' },
});
grid.appendTo('#Grid');
[]
toolbar
defines the ToolBar items of the Grid.
It contains built-in and custom toolbar items.
If a string value is assigned to the toolbar
option, it is considered as the template for the whole Grid ToolBar.
If an array value is assigned, it is considered as the list of built-in and custom toolbar items in the Grid’s Toolbar.
The available built-in ToolBar items are:
CsvExport - Export the Grid to CSV(csvExport() method manually to make export.)
The following code example implements the custom toolbar items.
Check the
Toolbar
to customize its default items.
<div id='Grid'></grid>
import { Grid, Toolbar } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
Grid.Inject(Toolbar);
let grid: Grid = new Grid({
dataSource: data,
toolbar: ['Search','Print'],
});
grid.appendTo('#Grid');
string
It used to render toolbar template
string
| number
Defines the Grid width.
<div id='Grid'></grid>
import { Grid } from '@syncfusion/ej2-grids';
import { data } from './datasource.ts';
let grid: Grid = new Grid({
dataSource: data,
width: '700',
});
grid.appendTo('#Grid');