欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

kendoui dropdownlist 绑定固定的值

程序员文章站 2022-06-11 22:46:21
...

Html元素 

<td>
    <input data-role="dropdownlist"
           data-auto-bind="true"
           data-value-primitive="false"
           data-text-field="Text"
           data-value-field="Value"
           data-bind="value: CloneEmployeeModel.WhetherForeign,source: WhetherForeignStatus,events:{change:WhetherForeignStatusChanged}" />
</td>

JS 

//是否是外籍人士
WhetherForeignStatus: new kendo.data.DataSource({
    transport: {
        read: {
            url: "/BaseData/WhetherForeignStatus",
        }
    },
    requestStart: function (e) {
    }
}),
WhetherForeignStatusChanged: function (e) {
    var selectdata = e.sender.dataItem(e.sender.select());
    this.set("CloneEmployeeModel.WhetherForeign", selectdata.Value);
},

后台: 

 public ActionResult WhetherForeignStatus()
 {
     var result = new List<BaseClass>()
       {
              new BaseClass() { Value = "1" , Text [email protected] },
              new BaseClass() { Value = "0" , Text [email protected] },
       };
     return Json(result, JsonRequestBehavior.AllowGet);
 }