标签:get man field text UNC pre required change color
1、在列后面增加editor和template属性,其中levelDropDownEditor是一个方法,LvDisplayName是下拉框的Text值的字段名(用于在列表里显示)
columns: [
{ field: "Name", expandable: true, title: "名称", width: 250 },
{ field: "Code", title: "编号" },
{ field: "Lv", title: "级别", width: "180px", editor: levelDropDownEditor, template: "#=LvDisplayName#" }
]
2、实现levelDropDownEditor方法,其中的DropdownlistValue,是我加上的特殊标识,用于后台的数据读取,因为后台自定了一个字段名叫:"LvDropdownlistValue"。
function levelDropDownEditor(container, options) { var jqueryElement = $(‘<input required name="‘ + options.field + ‘DropdownlistValue" />‘); jqueryElement .appendTo(container) .kendoDropDownList({ autoBind: true, dataTextField: "DisplayCode", dataValueField: "ParaCode", dataSource: { transport: { read: { dataType: "jsonp", url: "@Url.Content("~/BaseInfoManagement/Department/GetDepartmentLevelList")", } } }, value: options.model.Lv, dataBound: onDataBound }); }
3、后台update方法的实现
public JsonResult Update()
{
dvaContext context = new dvaContext();
JsonResult json = new JsonResult();
var tempObj = new Cust_department_info();
if (ModelState.IsValid)
{
string jsonData = this.Request["models"];
List<Cust_department_info> lst = JsonConvert.DeserializeObject<List<Cust_department_info>>(jsonData);
foreach (var obj in lst)
{
var objNew = context.department_info.Find(obj.ID);
List<department_info> children = context.department_info.Where(m => m.ParentCode == objNew.Code).ToList();
objNew.Name = obj.Name;
objNew.Code = obj.Code;
objNew.Lv = obj.LvDropdownlistValue.ParaCode;
foreach (var b in children)
{
b.ParentCode = objNew.Code;
}
}
context.SaveChanges();
}
json.Data = new { success = true, msg = "更新成功!" };
return json;
}
kendo ui treelist popup 模式下 实现下拉框控件形式展示
标签:get man field text UNC pre required change color
原文地址:https://www.cnblogs.com/wjx-blog/p/9419499.html