看别人写的Html.TreeView中的一段代码,连参数都那么霸气,比较合理 /// <summary> /// Create a TreeView of nodes starting from a root element /// </summary> /// <param name="treeId">The ID that will be used when the ul is created</param> /// <param name="rootItems">The root nodes to create</param> /// <param name="childrenProperty">A lambda expression that returns the children nodes</param> /// <param name="itemContent">A lambda expression defining the content in each tree node</param> public static string TreeView<T>(this HtmlHelper html, string treeId, IEnumerable<T> rootItems, Func<T, IEnumerable<T>> childrenProperty, Func<T, string> itemContent) { return html.TreeView(treeId, rootItems, childrenProperty, itemContent, true, null); } //例子 Html.TreeView("dropTree", Model.Locations, l => l.ChildrenLocations, l => "<a href='javascript:Edit(" + l.cat_id + ")' >" + l.cat_name + "</a>")
/// Create a TreeView of nodes starting from a root element
/// </summary>
/// <param name="treeId">The ID that will be used when the ul is created</param>
/// <param name="rootItems">The root nodes to create</param>
/// <param name="childrenProperty">A lambda expression that returns the children nodes</param>
/// <param name="itemContent">A lambda expression defining the content in each tree node</param>
public static string TreeView<T>(this HtmlHelper html, string treeId, IEnumerable<T> rootItems, Func<T, IEnumerable<T>> childrenProperty, Func<T, string> itemContent)
{
return html.TreeView(treeId, rootItems, childrenProperty, itemContent, true, null);
}
//例子
Html.TreeView("dropTree", Model.Locations, l => l.ChildrenLocations, l => "<a href='javascript:Edit(" + l.cat_id + ")' >" + l.cat_name + "</a>")
学的东西始终都会有用,要看你以什么养的态度去看待它~ 嘿嘿~~
让ORM框架支持多表(多实体)连接查询