Example of Custom Resize functionality in ASP.NET MVC AutoComplete Control
This example demonstrates the custom resizing functionalities of the AutoComplete. You can adjust the size of the popup based on your preferences, allowing for better control over its appearance.
@Html.UiAutoComplete("books", new UiAutoCompleteOptions
{
AllowResize = true,
Placeholder = "e.g. Node.js Succinctly",
DataSource = (IEnumerable<DropdownsDemoController.BooksData>)ViewData["data"],
Fields = new UiDropDownFields { Text = "BookName" }
})
<style>
.control-wrapper { margin: 0 auto; width: 250px; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section" style="height: 400px;">
<div class="control-wrapper">
<div style="padding-top:75px;">
@Html.UiAutoComplete("books", new UiAutoCompleteOptions
{
AllowResize = true,
Placeholder = "e.g. Node.js Succinctly",
DataSource = (IEnumerable<DropdownsDemoController.BooksData>)ViewData["data"],
Fields = new UiDropDownFields { Text = "BookName" }
})
</div>
</div>
</div>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class AutoCompleteController : Controller
{
// The page is Views/AutoComplete/Resize.cshtml; it draws what ViewData holds.
public ActionResult Resize()
{
ViewData["data"] = new BooksData().GetBooksData();
return View();
}
public class BooksData
{
public string BookName { get; set; }
public string BookID { get; set; }
public List<BooksData> GetBooksData()
{
List<BooksData> book = new List<BooksData>();
book.Add(new BooksData { BookName = "Support Vector Machines Succinctly", BookID = "BOOK1" });
book.Add(new BooksData { BookName = "Scala Succinctly", BookID = "BOOK2" });
book.Add(new BooksData { BookName = "Application Security in .NET Succinctly", BookID = "BOOK3" });
// ... 57 more rows
return book;
}
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The AutoComplete can be customized to adjust the size of the popup using custom resizing functionalities. By setting AllowResize to true, you enable the ability to resize the popup, allowing you to control its dimensions according to your preferences and providing better management of its appearance.