[英]kendo parameterMap return Undefined
我有一個 CostCenter ComboBox 試圖從 CompanyCode 組合框中獲取所選項目的 ID 並將其傳遞到 URL,但我不明白為什么我在 URL 中不斷收到“未定義”。
---JS---
$("#companyCode").width(500).kendoComboBox({
placeholder: "Select...",
dataTextField: "CompanyDescription",
dataValueField: "Id",
autobind: false,
template: "#: data.CompanyCode# - #: data.CompanyDescription#",
dataSource: {
serverFiltering: true,
transport: {
read: {
url: "./CompanyCodeCostCenter/GetAll",
// the request type
type: "get",
// the data type of the returned result
dataType: "json",
}
}
},
change: function () {
companyCodeId = this.value();
}
});
$("#costCenter").width(500).kendoComboBox({
placeholder: "Select...",
dataTextField: "CostCenterDescription",
dataValueField: "Id",
template: "#: data.CostCenterNo# - #: data.CostCenterDescription#",
autobind: false,
cascadeFrom: "companyCode",
dataSource: {
serverFiltering: true,
transport: {
read: {
url: "./CompanyCodeCostCenter/Get" + companyCodeId,
// the request type
type: "get",
// the data type of the returned result
dataType: "json",
},
parameterMap: function (data, type) {
if (type == "read" &&
data.filter != undefined &&
data.filter.filters != undefined ){
var filter = data.filter.filters;
return {
id: filter[0].value,
}
}
}
}
}
});
- -控制器 - -
public virtual JsonResult Get(int id)
{
SetUser();
var vo = _viewService.Get(id);
ExpirePage();
return Json(vo, JsonRequestBehavior.AllowGet);
}
- -結果 - -
http://localhost/Tax/CompanyCodeCostCenter/Getundefined?id=21
我對 JS 和 Kendo 很陌生。 如果可能,請詳細說明。 謝謝
我認為這篇文章應該可以幫助你實現你想要的: https : //docs.telerik.com/kendo-ui/controls/editors/combobox/cascading#what-to-do-when-i-cannot-get -服務器上的請求參數
$("#costCenter").width(500).kendoComboBox({
placeholder: "Select...",
dataTextField: "CostCenterDescription",
dataValueField: "Id",
template: "#: data.CostCenterNo# - #: data.CostCenterDescription#",
autobind: false,
cascadeFrom: "companyCode",
dataSource: {
serverFiltering: true,
transport: {
read: {
url: "./CompanyCodeCostCenter/Get" + companyCodeId,
// the request type
type: "get",
// the data type of the returned result
dataType: "json",
// use this instead of parameter map
data: function () {
return { id: $('#companyCode').val() }
}
}
}
}
});
我將data
屬性添加到了transport.read
對象。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.