所以,我正在尝试了解如何将数据导入Kendo UI小部件。小部件是treeview
。当然我想用remote data
来做。
因此,该网站的演示文档将我带到了这段代码中以获取数据。但我不知道发生了什么。我知道这是一个访问数据的sql语句。但是,我不确定一些语法。比如,?, hasChildren = e.Employees1.Any(), :
,方法的签名和return语句(我得到employees变量,但不是jsonRequestBehavior
)。
public JsonResult Employees(int? id)
{
var dataContext = new Client();
var employees = from e in dataContext.ClientName
where (id.HasValue ? e.ReportsTo == id : e.ReportsTo == null)
select new
{
id = e.EmployeeID,
Name = e.FirstName + " " + e.LastName,
hasChildren = e.Employees1.Any()
};
return Json(employees, JsonRequestBehavior.AllowGet);
}
最初的陈述是......
using System.Web.Mvc;
using System.Linq;
using Kendo.Mvc.Examples.Models;
namespace Kendo.Mvc.Examples.Controllers
{
public partial class TreeViewController : Controller
{
[Demo]
public ActionResult Remote_Data_Binding()
{
return View();
}
public JsonResult Employees(int? id)
{
var dataContext = new SampleEntities();
var employees = from e in dataContext.Employees
where (id.HasValue ? e.ReportsTo == id : e.ReportsTo == null)
select new {
id = e.EmployeeID,
Name = e.FirstName + " " + e.LastName,
hasChildren = e.Employees1.Any()
};
return Json(employees, JsonRequestBehavior.AllowGet);
}
}
}