製品版のみの機能
ツリー - ASP.NET MVC
このサンプルは、ASP.NET MVC ヘルパーを使用してツリー コントロールをサーバーのオブジェクト コレクションにバインドする方法を紹介します。
このサンプルは CTP 機能を使用しています。製品版では、API や動作が変更される場合があります。
このサンプルは、より大きい画面サイズのためにデザインされました。
モバイル デバイスで画面を回転、フル サイズ表示、またはその他のデバイスにメールで送信します。
コード ビュー
クリップボードへコピー
@using Infragistics.Web.Mvc
@using IgniteUI.SamplesBrowser.Models
@model IEnumerable<IgniteUI.SamplesBrowser.Models.Northwind.Category>
<!DOCTYPE html>
<html>
<head>
<title></title>
<!-- Ignite UI for jQuery Required Combined CSS Files -->
<link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
<link href="http://cdn-na.infragistics.com/igniteui/2024.2/latest/css/structure/infragistics.css" rel="stylesheet" />
<script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<!-- Ignite UI for jQuery Required Combined JavaScript Files -->
<script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.core.js"></script>
<script src="http://cdn-na.infragistics.com/igniteui/2024.2/latest/js/infragistics.lob.js"></script>
</head>
<body>
@(Html.Infragistics().Tree()
.DataSource(Model)
.Bindings(b =>
b.TextKey("CategoryName")
.ValueKey("ID")
.ChildDataProperty("Products")
.Bindings(b2 =>
b2.TextKey("ProductName")
.ValueKey("ID")
)
)
.DataBind()
.Render()
)
</body>
</html>
using IgniteUI.SamplesBrowser.Models.Northwind;
using IgniteUI.SamplesBrowser.Models.Repositories;
using Infragistics.Web.Mvc;
using System.Collections.Generic;
using System.Web.Mvc;
namespace IgniteUI.SamplesBrowser.Controllers
{
public class TreeController : Controller
{
//
// GET: /Tree/
[ActionName("aspnet-mvc-helper")]
public ActionResult AspNetMvcHelper()
{
IEnumerable<Category> categories = RepositoryFactory.GetCategoryRepository().Get();
return View("aspnet-mvc-helper", categories);
}
[ActionName("aspnet-mvc-load-on-demand")]
public ActionResult AspNetLoadOnDemand()
{
IEnumerable<Category> categories = RepositoryFactory.GetCategoryRepository().Get();
return View("aspnet-mvc-load-on-demand", categories);
}
[ActionName("tree-data-on-demand")]
public JsonResult TreeDataOnDemand(string path, string binding, int depth)
{
TreeModel model = new TreeModel();
switch (depth)
{
case 0:
model.DataSource = RepositoryFactory.GetCategoryRepository().Get();
break;
default:
model.DataSource = RepositoryFactory.GetCategoryRepository().Get();
break;
}
return model.GetData(path, binding);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace IgniteUI.SamplesBrowser.Models.Northwind
{
public class Category
{
public int ID { get; set; }
public string CategoryName { get; set; }
public string Description { get; set; }
public string ImageUrl { get; set; }
public int ProductCount { get; set; }
public IEnumerable<Product> Products { get; set; }
}
}