FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 4161|回复: 3
打印 上一主题 下一主题

DropDownList在动态绑定数据时,无法指定.DataSimulateTreeLevelFiel...

[复制链接]
跳转到指定楼层
楼主
发表于 2017-3-14 09:03:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
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
推荐
发表于 2017-3-14 11:49:09 | 只看该作者
可以通过 Source 属性来改变 UIHelper.DropDownList("DropDownList1") 返回的控件属性,类似如下代码:
  1. [HttpPost]
  2.         [ValidateAntiForgeryToken]
  3.         public ActionResult btnDataBind_Click(string DropDownList1, string DropDownList1_text)
  4.         {
  5.             var dropDownList1UI = UIHelper.DropDownList("DropDownList1");

  6.             // 通过 Source 设置控件属性
  7.             dropDownList1UI.Source.EnableSimulateTree = true;
  8.             dropDownList1UI.Source.DataSimulateTreeLevelField = "Level";
  9.             dropDownList1UI.Source.DataEnableSelectField = "EnableSelect";
  10.             // 绑定数据
  11.             dropDownList1UI.DataSource(GetData2(), "Id", "Name");
  12.             // 设置选中项
  13.             dropDownList1UI.SelectedValue("11");

  14.             return UIHelper.Result();
  15.         }
复制代码


下个版本,我会增加示例:



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
沙发
 楼主| 发表于 2017-3-14 09:05:13 | 只看该作者
var ddl = UIHelper.DropDownList("ParentID");
            ddl.DataSource(ResolveDDL(GetSys_DepartmentCoustonTree(nodeID)).ToArray(),"ID","Name");
ddl下无.DataSimulateTreeLevelField("TreeLevel")方法
地板
 楼主| 发表于 2017-3-15 09:40:07 | 只看该作者
OK了,谢谢三师兄的回复

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-4-28 16:46 , Processed in 0.047792 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表