- Setting text align
- Setting template
- Setting display as checkBox
- Setting custom attributes
Contact Support
Columns in React MultiColumn ComboBox component
14 Jun 202424 minutes to read
The columns property allows to define what data fields is to be displayed in the MultiColumn Combobox.
You can customize the column by using ColumnModel, which provides options such as field
, header
, width
, format
, template
and more.
-
field - Specifies the fields to be displayed in each column, mapped from the data source to the multicolumn combobox.
-
header - Specifes the data to be displayed in the column header.
-
width - Specifes the column width.
In the following example, the column is customized with field
, header
and width
properties.
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData: { [key: string]: Object }[] = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields: Object = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text: string = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
Setting text align
You can use the textAlign property to define the text alignment of the column.
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90} textAlign={'Right'}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData: { [key: string]: Object }[] = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields: Object = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text: string = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90} textAlign={'Right'}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
Setting template
You can use the template property to customize the each cell of the column. It accepts either a template string or an HTML element.
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const data = [
{ "Name": "Andrew Fuller", "Eimg": 7, "Designation": "Team Lead", "Country": "England", "DateofJoining": "12/10/2010" },
{ "Name": "Anne Dodsworth", "Eimg": 1, "Designation": "Developer", "Country": "USA", "DateofJoining": "10/05/2000" },
{ "Name": "Janet Leverling", "Eimg": 3, "Designation": "HR", "Country": "Russia", "DateofJoining": "23/02/2016" },
{ "Name": "Laura Callahan", "Eimg": 2, "Designation": "Product Manager", "Country": "Ukraine", "DateofJoining": "30/1/2012" },
{ "Name": "Margaret Peacock", "Eimg": 6, "Designation": "Developer", "Country": "Egypt", "DateofJoining": "15/08/2014" },
{ "Name": "Michael Suyama", "Eimg": 9, "Designation": "Team Lead", "Country": "Africa", "DateofJoining": "27/07/2015" },
{ "Name": "Nancy Davolio", "Eimg": 4, "Designation": "Product Manager", "Country": "Australia", "DateofJoining": "24/05/2017" },
{ "Name": "Robert King", "Eimg": 8, "Designation": "Developer ", "Country": "India", "DateofJoining": "08/09/2018" },
{ "Name": "Steven Buchanan", "Eimg": 10, "Designation": "CEO", "Country": "Ireland", "DateofJoining": "05/03/2020" }
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'Eimg' };
// set placeholder to multicolumn ComboBox input element
const waterMark = 'Select an employee';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" cssClass="multicolumn-customize" dataSource={data} fields={fields} popupHeight={230} placeholder={waterMark} gridSettings=>
<ColumnsDirective>
<ColumnDirective field='Eimg' header='Photos' width={90} template='<div><img class="empImage" src="https://ej2.syncfusion.com/demos/src/multicolumn-combobox/Employees/${Eimg}.png" alt="employee"/> </div>'></ColumnDirective>
<ColumnDirective field='Name' header='Employee Name' width={160} template='<div class="ename"> ${Name} </div> <div class="job"> ${Designation} </div>'></ColumnDirective>
<ColumnDirective field='DateofJoining' header='Date of Joining' width={165} template='<div class="dateOfJoining"> ${DateofJoining} </div>'></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={100} template='<div class="country"> ${Country} </div>'></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const data: { [key: string]: Object }[] = [
{ "Name": "Andrew Fuller", "Eimg": 7, "Designation": "Team Lead", "Country": "England", "DateofJoining": "12/10/2010" },
{ "Name": "Anne Dodsworth", "Eimg": 1, "Designation": "Developer", "Country": "USA", "DateofJoining": "10/05/2000" },
{ "Name": "Janet Leverling", "Eimg": 3, "Designation": "HR", "Country": "Russia", "DateofJoining": "23/02/2016" },
{ "Name": "Laura Callahan", "Eimg": 2, "Designation": "Product Manager", "Country": "Ukraine", "DateofJoining": "30/1/2012" },
{ "Name": "Margaret Peacock", "Eimg": 6, "Designation": "Developer", "Country": "Egypt", "DateofJoining": "15/08/2014" },
{ "Name": "Michael Suyama", "Eimg": 9, "Designation": "Team Lead", "Country": "Africa", "DateofJoining": "27/07/2015" },
{ "Name": "Nancy Davolio", "Eimg": 4, "Designation": "Product Manager", "Country": "Australia", "DateofJoining": "24/05/2017" },
{ "Name": "Robert King", "Eimg": 8, "Designation": "Developer ", "Country": "India", "DateofJoining": "08/09/2018" },
{ "Name": "Steven Buchanan", "Eimg": 10, "Designation": "CEO", "Country": "Ireland", "DateofJoining": "05/03/2020" }
];
// maps the appropriate column to fields property
const fields: Object = { text: 'Name', value: 'Eimg' };
// set placeholder to multicolumn ComboBox input element
const waterMark: string = 'Select an employee';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" cssClass="multicolumn-customize" dataSource={data} fields={fields} popupHeight={230} placeholder={waterMark} gridSettings=>
<ColumnsDirective>
<ColumnDirective field='Eimg' header='Photos' width={90} template='<div><img class="empImage" src="https://ej2.syncfusion.com/demos/src/multicolumn-combobox/Employees/${Eimg}.png" alt="employee"/> </div>'></ColumnDirective>
<ColumnDirective field='Name' header='Employee Name' width={160} template='<div class="ename"> ${Name} </div> <div class="job"> ${Designation} </div>'></ColumnDirective>
<ColumnDirective field='DateofJoining' header='Date of Joining' width={165} template='<div class="dateOfJoining"> ${DateofJoining} </div>'></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={100} template='<div class="country"> ${Country} </div>'></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
Setting display as checkBox
You can use displayAsCheckBox property to display the column value as checkbox instead of a boolean value. By default, the value is false
.
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90} displayAsCheckBox={true}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90} displayAsCheckBox={true}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90}></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
Setting custom attributes
You can use the customAttributes property to customize the CSS styles and attributes of each column’s content cells.
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" }
];
// maps the appropriate column to fields property
const fields = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90} customAttributes=></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));
import { MultiColumnComboBoxComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-multicolumn-combobox';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
function App() {
// defined the array of object data
const empData: { [key: string]: Object }[] = [
{ "EmpID": 1001, "Name": "Andrew Fuller", "Designation": "Team Lead", "Country": "England" },
{ "EmpID": 1002, "Name": "Robert", "Designation": "Developer", "Country": "USA" },
{ "EmpID": 1003, "Name": "Michael", "Designation": "HR", "Country": "Russia" },
{ "EmpID": 1004, "Name": "Steven Buchanan", "Designation": "Product Manager", "Country": "Ukraine" },
{ "EmpID": 1005, "Name": "Margaret Peacock", "Designation": "Developer", "Country": "Egypt" },
{ "EmpID": 1006, "Name": "Janet Leverling", "Designation": "Team Lead", "Country": "Africa" },
{ "EmpID": 1007, "Name": "Alice", "Designation": "Product Manager", "Country": "Australia" },
{ "EmpID": 1008, "Name": "Bob", "Designation": "Developer", "Country": "India" },
{ "EmpID": 1009, "Name": "John", "Designation": "Product Manager", "Country": "Ireland"},
{ "EmpID": 1010, "Name": "Mario Pontes", "Designation": "Team Lead", "Country": "South Africa" },
{ "EmpID": 1011, "Name": "Yang Wang", "Designation": "Developer", "Country": "Russia" },
{ "EmpID": 1012, "Name": "David", "Designation": "Product Manager", "Country": "Egypt" },
{ "EmpID": 1013, "Name": "Antonio Bianchi", "Designation": "Team Lead", "Country": "USA" },
{ "EmpID": 1014, "Name": "Laura", "Designation": "Developer", "Country": "England" },
{ "EmpID": 1015, "Name": "Carlos Hernandez", "Designation": "Developer", "Country": "Canada" },
{ "EmpID": 1016, "Name": "Lily", "Designation": "Product Manager", "Country": "France" },
{ "EmpID": 1017, "Name": "Tom Williams", "Designation": "Developer", "Country": "Ukraine" },
{ "EmpID": 1018, "Name": "Grace", "Designation": "Developer", "Country": "Australia" },
{ "EmpID": 1019, "Name": "Olivia", "Designation": "Team Lead", "Country": "Ireland" },
{ "EmpID": 1020, "Name": "James", "Designation": "Developer", "Country": "China" },
];
// maps the appropriate column to fields property
const fields: Object = { text: 'Name', value: 'EmpID' };
// set text to multicolumn ComboBox input element
const text: string = 'Michael';
return (
// specifies the tag for render the MultiColumn ComboBox component
<MultiColumnComboBoxComponent id="multicolumn" dataSource={empData} fields={fields} text={text}>
<ColumnsDirective>
<ColumnDirective field='EmpID' header='Employee ID' width={90}></ColumnDirective>
<ColumnDirective field='Name' header='Name' width={90} customAttributes=></ColumnDirective>
<ColumnDirective field='Designation' header='Designation' width={90}></ColumnDirective>
<ColumnDirective field='Country' header='Country' width={70}></ColumnDirective>
</ColumnsDirective>
</MultiColumnComboBoxComponent>
);
}
ReactDOM.render(<App />, document.getElementById('multicolumn'));