Data Entry Made Easy with Blazor Multicolumn AutoComplete | Syncfusion Blogs
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)
Data Entry Made Easy with Blazor Multicolumn AutoComplete

Data Entry Made Easy with Blazor Multicolumn AutoComplete

The Syncfusion Blazor AutoComplete is a text box component that provides a list of suggestions to select from as the user types. It has several out-of-the-box features such as data binding, filtering, grouping, UI customization, and accessibility.

In this blog post, we will learn how to create a multicolumn AutoComplete component by customizing its template. You will also learn how to configure and bind the data in the Syncfusion Blazor AutoComplete component to make it display search results in multiple columns.

Purpose of the multicolumn data list

A standard Autocomplete search result will display a list of items in a single column. So, only a single piece of information about each item can be displayed in any instance.

Example: Displaying a list of product names.

But a multicolumn Autocomplete displays a list of search result items in multiple columns like in a data grid view. So, we can use it to display more information about items in a single list.

Example: Displaying a list of product names with their unit prices and the units in stock. We may also display more information, like units on order and discounts, with multicolumn data grid view support.

Let’s create a multicolumn AutoComplete component in the Blazor platform!

Prerequisites

Create a Blazor WebAssembly application

In this example, we are going to display the following information regarding products:

  • Product ID
  • Name
  • Unit price
  • Units in stock
  • Units on order

Step 1: Let’s create a Blazor WebAssembly app and create a new model class file inside the DataModel folder with the name Product.

public class Product
    {
        public int? ProductID { get; set; }
        public string ProductName { get; set; }
        public int? SupplierID { get; set; }
        public double? UnitPrice { get; set; }
        public int UnitsInStock { get; set; }
        public int UnitsOnOrder { get; set; }
    }

Step 2: After creating the model class, add the method GetProducts() to get the product data.

Add AutoComplete component and configure the multicolumn data grid view

Second, we add the Syncfusion Blazor AutoComplete component to the created Blazor WebAssembly app.

Step 1: Add the following code example in the index.razor file to create a simple AutoComplete component and bind its source to the product list.

<SfAutoComplete TValue="string" TItem="Product" DataSource="@_productsList" PopupHeight="400px" Placeholder="Select a Product">
       <AutoCompleteFieldSettings Value="ProductName"></AutoCompleteFieldSettings>
</SfAutoComplete>

Step 2: Next, get the data from the product service and assign it to the AutoComplete DataSource API with the OnInitialized method.

@code{
    private IEnumerable<Product> _productsList;

    protected override void OnInitialized()
    {
        _productsList = new Product().GetProducts();
    }
}

Step 3: Now, we need to display the pop-up list items in a multicolumn view to show more information when the user opens AutoComplete’s pop-up. To do so, use:

Refer to the following code example.

<SfAutoComplete TValue="string" TItem="Product" PopupWidth="700px" DataSource="@_productsList" PopupHeight="400px" Placeholder="Select a Product">
               <AutoCompleteTemplates TItem="Product">
                  <HeaderTemplate>
                            <table><tr><th class="e-text-center">Product ID</th><th width="240px">Product Name</th><th>Unit Price</th><th>Units In Stock</th><th>Units On Order</th></tr></table>
                 </HeaderTemplate>
                 <ItemTemplate>
                   <table><tbody><tr><td class="e-text-center">@((context as Product).ProductID)</td><td width="240px">@((context as Product).ProductName)</td><td>@((context as Product).UnitPrice)</td><td>@((context as Product).UnitsInStock)</td><td>@((context as Product).UnitsOnOrder)</td></tr> </tbody></table>
                 </ItemTemplate>
            </AutoCompleteTemplates>
       <AutoCompleteFieldSettings Value="ProductName"></AutoCompleteFieldSettings>
</SfAutoComplete>

Step 4: The multicolumn style class is available inbuilt in the Syncfusion Blazor theme files. In the CssClass API, name the multicolumn root class e-multi-column.

<SfAutoComplete TValue="string" TItem="Product" PopupWidth="700px" DataSource="@_productsList" PopupHeight="400px" CssClass="e-multi-column" Placeholder="Select a Product">
      <AutoCompleteFieldSettings Value="ProductName"></AutoCompleteFieldSettings>
</SfAutoComplete>

When executing the previous code example, we’ll get output like in the following screenshot. See how it displays the AutoComplete list item information in the multicolumn data grid view.
Output

Display customized information in data grid

We can customize the alignment of the text displayed in each column using a built-in class. The following are the text alignment options available:

  • e-text-center: Displays the text in the center of the column.
  • e-text-right: Displays the text on the right side of the column.
  • e-text-left: Displays the text on the left side of the column.
<AutoCompleteTemplates TItem="Product">
       <HeaderTemplate>
         <table><tr><th class="e-text-center">Product ID</th><th width="240px">Product Name</th><th>Unit Price</th><th>Units In Stock</th><th>Units On Order</th></tr></table>
        </HeaderTemplate>
         <ItemTemplate>
           <table><tbody><tr><td class="e-text-center">@((context as Product).ProductID)</td><td width="240px">@((context as Product).ProductName)</td><td>@((context as Product).UnitPrice)</td><td>@((context as Product).UnitsInStock)</td><td>@((context as Product).UnitsOnOrder)</td></tr> </tbody></table>
          </ItemTemplate>
</AutoCompleteTemplates>

GitHub reference

You can download the complete source code of this example from the GitHub repository.

Conclusion

Thanks for reading! I hope you can now add and display AutoComplete search result items in a multicolumn data grid view. You can easily customize the pop-up and list items using the template options. See more samples in this demo.

Feel free to have a look at our online examples and documentation to explore other available features.

Try our Blazor AutoComplete component by downloading a free 30-day trial or from our NuGet package.

If you have any questions, please let us know in the comments section below. You can also contact us through our support forum , Direct-Trac or feedback portal. We are always happy to assist you!

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed