kendoui dropdownlist 绑定固定的值

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);
 }

猜你喜欢

转载自blog.csdn.net/weixin_41392824/article/details/81876018