我试图从jstree获取所选节点.
这是View中的代码
<div id="divtree" >
<ul id="tree" >
@foreach (var m in Model.presidentList)
{
<li class="jstree-clicked">
<a href="#" class="usr">@m.Name</a>
@Html.Partial("Childrens", m)
</li>
}
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我试图检索节点名称的javascript部分
$(".jstree-clicked").click(function (e) {
var node = $(this).jstree('get_selected').text();
alert(node);
});
Run Code Online (Sandbox Code Playgroud)
我在获取所选节点时遇到问题.如果我选择其中一个子节点(例如树的最后一个节点),我仍然可以获得整个节点列表.如果您知道我在哪里做错了,请告诉我?
我在将数据从数据库发送到Controller中的列表时遇到问题.我是C#和MVC的新手,所以任何帮助都会有用!代码如下
public static List<FilterTree> GetAllUsers()
{
FilterTreeDBContext db = new FilterTreeDBContext();
var userList = new List<FilterTree>();
var device = new FilterTree();
//This is the line where I get the error
device.ID = from a in db.FilterTree select a.ID;
userList.Add(device);
return userList;
}
Run Code Online (Sandbox Code Playgroud)
谢谢,节日快乐!:)