0
我有这个任务需要在html中构建父/子视图。不使用任何插件!ASP.NET MVC构建子/父树
我已经在子节点的控制器中创建了一个数据库和一个模型(H_Table)以及一个类(Element)。 但是,我如何得到这个一起工作。因此,它从模型中检索数据将其传递给类并返回查看模型。我不确定我是否正确地解释它。询问。
我的模型:
namespace Tree_List.Models
{
using System;
using System.Collections.Generic;
public partial class H_Table
{
public int ID { get; set; }
public string NAME { get; set; }
public Nullable<int> PARENT_ID { get; set; }
}
}
我的控制器:
using System.Collections.Generic;
using System.Web.Mvc;
using Tree_List.Models;
namespace Tree_List.Controllers
{
public class ListController : Controller
{
// GET: List
private Models.ListDBEntities1 db_connection = new Models.ListDBEntities1();
public ActionResult Index()
{
var Items = db_connection.H_Table;
return View(Items);
}
}
public partial class Element
{
public int ID { get; set; }
public string NAME { get; set; }
public List<Element> CHILDS { get; set; }
}
}
与数据表去,https://datatables.net/examples/api/row_details.html。 – Bharat
@Bharat我很少使用插件!用于数据表的 – SonOfAGun
,你只需要js文件,没有别的。它很容易使用.. – Bharat