|
DropDownList在初始化时,可以指定.DataSimulateTreeLevelField("TreeLevel"),在.OnSelectedIndexChanged(Url.Action("ddlSheng_SelectedIndexChanged"), "Form1"),事件中,页面中的.DataSimulateTreeLevelField("TreeLevel")无效,
public ActionResult Edit(string id, string nodeID)
{
Sys_Department sys_Department = id == null ? new Sys_Department() : db.Sys_Departments.Find(id);
if (sys_Department == null)
{
return HttpNotFound();
}
string orgnizationID = nodeID == null ? "-1" : nodeID;
sys_Department.sys_Orgnization_ID = sys_Department.ID == null ? orgnizationID : sys_Department.sys_Orgnization_ID;
sys_Department.SortIndex = sys_Department.ID == null ? db.Sys_Departments.Where(m => m.sys_Orgnization_ID == nodeID).Count() + 1 : sys_Department.SortIndex;
ViewBag.ParentID = ResolveDDL(GetSys_DepartmentCoustonTree(nodeID), sys_Department.ParentID);
ViewBag.sys_Orgnization_ID = ResolveDDL(GetSys_OrgnizationCoustonTree(null), null, false);
return View(sys_Department);
}
这是初始化时的数据源
F.DropDownListFor(m => m.sys_Orgnization_ID).Label("所属机构")
.EnableSimulateTree(true)
.DataTextField("Name").DataValueField("ID")
.DataSimulateTreeLevelField("TreeLevel")
.DataEnableSelectField("Enabled")
.DataSource(ViewBag.sys_Orgnization_ID)
.OnSelectedIndexChanged(Url.Action("ddlSheng_SelectedIndexChanged"), "Form1"),
F.DropDownListFor(m => m.ParentID).Label("所属部门")
.EnableSimulateTree(true)
.DataTextField("Name").DataValueField("ID")
.DataSimulateTreeLevelField("TreeLevel")
.DataEnableSelectField("Enabled")
.DataSource(ViewBag.ParentID)
这是前台页面数据
这是所属机构的事件
public ActionResult ddlSheng_SelectedIndexChanged(FormCollection values)
{
var nodeID = values["sys_Orgnization_ID"];
var ddl = UIHelper.DropDownList("ParentID");
ddl.DataSource(ResolveDDL(GetSys_DepartmentCoustonTree(nodeID)).ToArray(),"ID","Name");
ddl.SelectedValue("-1");
return UIHelper.Result();
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|