Example of Overview in ASP.NET MVC FAB Control
This sample demonstrates the usage of the Floating Action Button (FAB) controller to add a new record to a DataGrid.
@Html.UiGrid(new UiGridOptions
{
Id = "Grid",
Data = (List<ButtonsDemoController.OrderDetails>)ViewData["order"],
AllowPaging = false,
EditSettings = new UiEditSettings { AllowAdding = true, Mode = UiEditMode.Dialog },
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "OrderID", HeaderText = "Order ID", Type = UiColumnType.Number, IsPrimaryKey = true, Width = 110 },
new UiGridColumn { Field = "CustomerID", HeaderText = "Customer Name", Width = 180 },
new UiGridColumn { Field = "Freight", HeaderText = "Freight", Type = UiColumnType.Number, Format = "N2", Width = 120 },
new UiGridColumn { Field = "ShipCountry", HeaderText = "Ship Country", Width = 150 }
}
})
@Html.UiFab(new UiFabOptions { Id = "Fab", Target = "target", Position = UiFabPosition.BottomRight, Title = "Add", IconCss = "ui-icon-plus", Color = UiButtonColor.Primary, OnClick = "addRecord" })
<style>
.fab-grid-container { position: relative; max-width: 720px; margin: 0 auto; padding-bottom: 72px; }
</style>
@using Lumen.UI.Mvc.Demo.Controllers
<div class="control-section">
<div id="target" class="fab-grid-container custom-index">
@Html.UiGrid(new UiGridOptions
{
Id = "Grid",
Data = (List<ButtonsDemoController.OrderDetails>)ViewData["order"],
AllowPaging = false,
EditSettings = new UiEditSettings { AllowAdding = true, Mode = UiEditMode.Dialog },
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "OrderID", HeaderText = "Order ID", Type = UiColumnType.Number, IsPrimaryKey = true, Width = 110 },
new UiGridColumn { Field = "CustomerID", HeaderText = "Customer Name", Width = 180 },
new UiGridColumn { Field = "Freight", HeaderText = "Freight", Type = UiColumnType.Number, Format = "N2", Width = 120 },
new UiGridColumn { Field = "ShipCountry", HeaderText = "Ship Country", Width = 150 }
}
})
@Html.UiFab(new UiFabOptions { Id = "Fab", Target = "target", Position = UiFabPosition.BottomRight, Title = "Add", IconCss = "ui-icon-plus", Color = UiButtonColor.Primary, OnClick = "addRecord" })
</div>
</div>
<script>
// Syncfusion: the button adds a record to the grid.
function addRecord() {
window.Lumen.get('Grid').addRecord();
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class FABController : Controller
{
// The page is Views/FAB/Overview.cshtml; it draws what ViewData holds.
public ActionResult Overview()
{
List<OrderDetails> order = new List<OrderDetails>();
order.Add(new OrderDetails(10248, "VINET", 32.38, "France"));
order.Add(new OrderDetails(10249, "TOMSP", 11.61, "Germany"));
order.Add(new OrderDetails(10250, "HANAR", 65.83, "Brazil"));
order.Add(new OrderDetails(10251, "VICTE", 41.34, "France"));
order.Add(new OrderDetails(10252, "SUPRD", 51.3, "Belgium"));
order.Add(new OrderDetails(10253, "HANAR", 58.17, "Brazil"));
order.Add(new OrderDetails(10254, "CHOPS", 22.98, "Switzerland"));
order.Add(new OrderDetails(10255, "RICSU", 148.33, "Switzerland"));
order.Add(new OrderDetails(10256, "WELLI", 13.97, "Brazil"));
order.Add(new OrderDetails(10257, "HILAA", 81.91, "Venezuela"));
ViewData["order"] = order;
return View();
}
public class OrderDetails
{
public OrderDetails()
{
}
public OrderDetails(int OrderID, string CustomerId, double Freight, string ShipCountry)
{
this.OrderID = OrderID;
this.CustomerID = CustomerId;
this.Freight = Freight;
this.ShipCountry = ShipCountry;
}
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public double? Freight { get; set; }
public string ShipCountry { get; set; }
}
}
}
@* 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 FAB is a button that appears in front of all screen contents and performs the primary action. In this example, FAB is positioned at the bottom left of its target DataGrid to perform the add new record action.