React Multicolumn MultiSelect Dropdown Component
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (173).NET Core  (29).NET MAUI  (203)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (211)BoldSign  (13)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (65)Flutter  (132)JavaScript  (219)Microsoft  (118)PDF  (81)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (897)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (50)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (127)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (63)Development  (618)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (39)Extensions  (22)File Manager  (6)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  (501)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (42)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  (381)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (17)Web  (582)What's new  (323)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
React Multicolumn MultiSelect Dropdown Component

React Multicolumn MultiSelect Dropdown Component

This blog post will look at the Syncfusion React MultiSelect Dropdown component. Learn how to create and configure multiple columns in it using the template feature.

Use of the multicolumn data list

The MultiSelect Dropdown displays list items in multiple columns, like in a grid view. So, it displays more information in a single list.

Let’s suppose the user wants to select products based on unit price and units in stock. So, we provide options to allow users to filter by their search criteria (by unit price, for example). This gives them a quick and detailed glance at all relevant information regarding a product.

Using the Syncfusion React MultiSelect Dropdown, let’s efficiently implement multiple columns with the templates feature.

Create a new React application

Step 1: We’ll create the React getting started application.

First, install the create-react-app npm package in the desired location using the following command.

npx create-react-app my-app

Then, refer to the Getting Started with React Apps documentation to create a React app using the npm and yarn commands.

Step 2: Add Syncfusion packages for the MultiSelect Dropdown with the following commands.

npm install @syncfusion/ej2-react-dropdowns –save-dev

Step 3: Add the following CSS files as references for the component in the src/App.css file. These files are available in the ../node_modules/@syncfusion package folder.

@import '../node_modules/@syncfusion/ej2-base/styles/bootstrap5.css';
@import '../node_modules/@syncfusion/ej2-icons/styles/bootstrap5.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/bootstrap5.css';
@import '../node_modules/@syncfusion/ej2-lists/styles/bootstrap5.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/bootstrap5.css';
@import '../node_modules/@syncfusion/ej2-react-dropdowns/styles/bootstrap5.css';

Step 4: Place the following code in the src/App.js file to add the MultiSelect Dropdown component.

import './App.css';
import { MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';

function App() {
 return (
  // specifies the tag for rendering the MultiSelect component
  <div id="default" className='center' style={{ width: '500px'}}>
   <MultiSelectComponent placeholder="Select the products" floatLabelType="auto"/>
  </div>
 );
}
export default App;

Step 5: Configure the product data and map the field settings to populate the list in the pop-up.

// define the JSON of data
const productsData = [
  {ProductID: 1, ProductName: 'Chai', UnitPrice: 18, UnitsInStock: 39},
  {ProductID: 2, ProductName: 'Chang', UnitPrice: 19, UnitsInStock: 45},
  {ProductID: 3, ProductName: 'Aniseed Syrup', UnitPrice: 23, UnitsInStock: 79},
  {ProductID: 4, ProductName: 'Chef Anton Cajun Seasoning', UnitPrice: 28, UnitsInStock: 28},
  {ProductID: 5, ProductName: 'Gumbo Mix', UnitPrice: 11, UnitsInStock: 50},
  {ProductID: 6, ProductName: 'Grandma Boysenberry', UnitPrice: 37, UnitsInStock: 49},
  {ProductID: 7, ProductName: 'Northwoods Cranberry Sauce', UnitPrice: 23, UnitsInStock: 91},
  {ProductID: 8, ProductName: 'Mishi Kobe Niku', UnitPrice: 32, UnitsInStock: 16},
  {ProductID: 9, ProductName: 'Ikura', UnitPrice: 80, UnitsInStock: 29},
  {ProductID: 10, ProductName: 'Uncle Bob Organic Dried Pears', UnitPrice: 26, UnitsInStock: 32},
  {ProductID: 11, ProductName: 'Organic Dried Pears', UnitPrice: 29, UnitsInStock: 19}
];
// maps the appropriate column to the fields property
const fields = { text: 'ProductName', value: 'ProductID' }; 
return (
  // specifies the tag for rendering the MultiSelect component
  <div id="default" className='center' style={{ width: '500px'}}>
   <MultiSelectComponent placeholder="Select the products" floatLabelType="auto" dataSource={productsData} fields={fields} />
  </div>
);

Step 6: Now, we need to display the pop-up list item in a multicolumn view to show more information when the user opens it. Use the item template to display column data in the table view and the header template to display the table of column names.

// set the value to the header template
function headerTemplate(data) {
  return (<table><tr><th className='e-text-center'>ProductID</th><th>Product Name</th><th className='e-text-center'>Unit Price</th><th className='e-text-center'>Units In Stock</th></tr></table>);
}
// set the value to the item template
function itemTemplate(data) {
  return (<table><tbody><tr><td className='e-text-center'>{data.ProductID}</td><td>{data.ProductName}</td><td className='e-text-center'>{data.UnitPrice}</td><td className='e-text-center'>{data.UnitsInStock}</td></tr></tbody></table>);
}
return (
 // specifies the tag for rendering the MultiSelect component
 <div id="default" className='center' style={{ width: '500px'}}>
   <MultiSelectComponent placeholder="Select the products" floatLabelType="auto" headerTemplate={headerTemplate} itemTemplate={itemTemplate} dataSource={productsData} fields={fields} />
 </div>
);

Step 7: We configure the multicolumn CSS class. We have provided the multicolumn style class in the built-in Syncfusion React theme files. We need to give the multicolumn root class name e-multi-column in the cssClass API.

<MultiSelectComponent cssClass='e-multi-column' />

Run the application with the following command.

npm start

After executing the previous code examples, we’ll get output like the following screenshot. See how it displays the MultiSelect Dropdown pop-up list items information in the multicolumn view.React Multicolumn MultiSelect Dropdown Component

GitHub reference

For additional information, see the GitHub demo of the React MultiSelect Dropdown component with multiple columns.

Conclusion

Thank you for your time! I hope you can now add and show MultiSelect Dropdown items in a multicolumn view. Using the template option, you can alter the pop-up and list items, as seen in the examples in this demo.

The latest version of Essential Studio is available from the license and downloads page for current Syncfusion customers. If you are not a client, you can take advantage of our 30-day free trial to test our controls.

If you have questions, please contact us via our support forumsfeedback portal, or support portal. We are always delighted to help!

Related blogs

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed