我有telerik下拉列表
@(Html.Telerik().DropDownList().Name("InstrumentType").BindTo(Model.MITypesList).Enable(!Model.IsReadOnlyOtherProperties).HtmlAttributes(new { @class = "instrument-type" }))
左边我有按钮添加('add-type-mi'),由ajax
保存到db$(".add-type-mi").on("click", function (e) {
e.preventDefault();
var choiсeMi = $("#choiсe-type-mi");
choiсeMi.find(".btnSubmit").one("click", function () {
var nameId = choiсeMi.find(".className").attr('id');
var nameType = choiсeMi.find(".className").val();
var categoryId = choiсeMi.find(".classCategory").attr('id');
var categoryName = choiсeMi.find(".classCategory").val();
var strVal = [{ name: nameId, value: nameType }, { name: categoryId, value: categoryName }];
$.ajax({
type: "POST",
url: $('#saveType').data('save-type'),
data: { "stringValues": JSON.stringify(strVal), "tableValues": [] },
cache: false,
dataType: 'json',
success: function (data) {
//this I need to bind data.title to dropdownlist
choiсeMi.data('tWindow').close();
}
});
});
choiсeMi.find(".btnCancel").one("click", function () {
choiсeMi.data('tWindow').close();
});
choiсeMi.data('tWindow').center().open();
});
我需要将我的数据绑定到dropdownlist('InstrumentType')而不更新页面
答案 0 :(得分:0)
绑定json我使用dataBind() 成功后有我的代码:function
var instrumentTypeList = $("#InstrumentType").data("tDropDownList");
var arrayList = instrumentTypeList.data;
if (arrayList == undefined) {
arrayList = [];
}
arrayList.push({ Text: data.objFullName, Value: data.id });
instrumentTypeList.dataBind(arrayList);