Example of Empty Record Template in ASP.NET MVC Tree Grid Control
This sample demonstrates the use of the empty record template in the Tree Grid. The EmptyRecordTemplate accepts either a string or an HTML element value, which will be used as the template when there is no data.
There is no data available to display at the moment.
@Html.UiTreeGrid(new UiTreeGridOptions
{
Id = "EmptyRecordTemplate",
Data = new List<object>(),
AllowFiltering = true,
FilterType = UiGridFilterType.Menu,
EmptyRecordTemplate = "#emptyrecordtemplate",
ChildMapping = "subtasks",
Toolbar = new List<string> { "Add", "Update", "Cancel", "Delete", "Search" },
EditSettings = new UiEditSettings { AllowAdding = true, AllowDeleting = true },
TreeColumnIndex = 1,
AllowPaging = true,
PageSize = 12,
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "taskID", HeaderText = "Task ID", Type = UiColumnType.Number, Width = 120, TextAlign = UiTextAlign.Right, IsPrimaryKey = true, ValidationRules = new UiValidationRules { Required = true, Min = 0 } },
new UiGridColumn { Field = "taskName", HeaderText = "Task Name", Width = 120, TextAlign = UiTextAlign.Left, ValidationRules = new UiValidationRules { Required = true } },
new UiGridColumn { Field = "priority", HeaderText = "Priority", Width = 100, TextAlign = UiTextAlign.Left, EditType = UiEditType.DropDownEdit, EditItems = new List<string> { "Low", "Medium", "High", "Critical" } },
new UiGridColumn { Field = "assignee", HeaderText = "Assignee", Width = 100, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "status", HeaderText = "Status", Width = 90, TextAlign = UiTextAlign.Left, EditType = UiEditType.DropDownEdit, EditItems = new List<string> { "Open", "In progress", "Review-Request", "Review-Reject", "Closed" } },
new UiGridColumn { Field = "duration", HeaderText = "Duration in Days", Type = UiColumnType.Number, Width = 150, TextAlign = UiTextAlign.Right, EditType = UiEditType.NumericEdit }
}
})
<style>
.emptyRecordTemplate { text-align: center; margin: 31px auto; }
.emptyRecordTemplate .e-emptyRecord { display: block; margin: 10px auto; }
</style>
<template id="emptyrecordtemplate">
<div class="emptyRecordTemplate">
<svg class="e-emptyRecord" width="120" height="90" viewBox="0 0 120 90" role="img" aria-label="No record" xmlns="http://www.w3.org/2000/svg"><rect x="14" y="14" width="92" height="62" rx="6" fill="none" stroke="#9aa0a6" stroke-width="3"/><path d="M26 34h68M26 48h46M26 62h30" stroke="#c4c7cc" stroke-width="4" stroke-linecap="round"/></svg>
<div><b>There is no data available to display at the moment.</b></div><br>
</div>
</template>
@Html.UiTreeGrid(new UiTreeGridOptions
{
Id = "EmptyRecordTemplate",
Data = new List<object>(),
AllowFiltering = true,
FilterType = UiGridFilterType.Menu,
EmptyRecordTemplate = "#emptyrecordtemplate",
ChildMapping = "subtasks",
Toolbar = new List<string> { "Add", "Update", "Cancel", "Delete", "Search" },
EditSettings = new UiEditSettings { AllowAdding = true, AllowDeleting = true },
TreeColumnIndex = 1,
AllowPaging = true,
PageSize = 12,
Selection = UiGridSelection.Single,
Columns = new List<UiGridColumn>
{
new UiGridColumn { Field = "taskID", HeaderText = "Task ID", Type = UiColumnType.Number, Width = 120, TextAlign = UiTextAlign.Right, IsPrimaryKey = true, ValidationRules = new UiValidationRules { Required = true, Min = 0 } },
new UiGridColumn { Field = "taskName", HeaderText = "Task Name", Width = 120, TextAlign = UiTextAlign.Left, ValidationRules = new UiValidationRules { Required = true } },
new UiGridColumn { Field = "priority", HeaderText = "Priority", Width = 100, TextAlign = UiTextAlign.Left, EditType = UiEditType.DropDownEdit, EditItems = new List<string> { "Low", "Medium", "High", "Critical" } },
new UiGridColumn { Field = "assignee", HeaderText = "Assignee", Width = 100, TextAlign = UiTextAlign.Left },
new UiGridColumn { Field = "status", HeaderText = "Status", Width = 90, TextAlign = UiTextAlign.Left, EditType = UiEditType.DropDownEdit, EditItems = new List<string> { "Open", "In progress", "Review-Request", "Review-Reject", "Closed" } },
new UiGridColumn { Field = "duration", HeaderText = "Duration in Days", Type = UiColumnType.Number, Width = 150, TextAlign = UiTextAlign.Right, EditType = UiEditType.NumericEdit }
}
})
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TreeGridController : Controller
{
// The page is Views/TreeGrid/EmptyRecordTemplate.cshtml; it draws what ViewData holds.
public ActionResult EmptyRecordTemplate()
{
return View();
}
}
}
@* 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>