考虑到一些因素,还是需要将select的数据传入Model中进行保存,所以得做如下修改。
@*控制碼*@
<label class="control-label col-sm-2">
控制碼<font class="red">*</font>
</label>
<select id="STEUS" class="col-sm-2 form-control" style="margin-top:1px;" title="控制碼" οnchange="KStarForm.koContentModel.WC.STEUS($('#STEUS').val());" disabled>
@*<option value="PP01" selected>PP01</option>*@
</select>
function get_STEUS_SelectData() {
$.ajax({
type: "post",
url: "/领域名/控制器名字/Get_STEUS_SelectData",
async: false,
data: {},
dataType: "JSON",
success: function (data) {
var str = null;
//控制碼select
for (i = 0; i < data.length; i++) {
if (data[i][0] == "PP01") {
str += "<option value='" + data[i][0] + "' selected>" + data[i][0] + " " + data[i][1] + "</option>";
} else {
str += "<option value='" + data[i][0] + "'>" + data[i][0] + " " + data[i][1] + "</option>";
}
}
$("#STEUS").html(str);
$("#STEUS").val("PP01");//初始化默认值
KStarForm.koContentModel.WC.STEUS("PP01");//初始化默认值
}
});
}
ajax返回的数据类型为List<List<string>>;
Model:
WorkCenter WC;
public WorkCenter{
public string STEUS { get; set; }
.......
}