亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將所選值 Id 從父項傳遞給子項 Kendo DropdownList

將所選值 Id 從父項傳遞給子項 Kendo DropdownList

紅糖糍粑 2023-07-29 16:22:03
我有一個使用 jquery 和 Kendo UI 的級聯 Kendo DropdownList。我的問題是,我想將選定的值 Id 從父級傳遞給子級,這意味著將 StateId 傳遞到城市 DropdownList 并根據選定的 StateId 過濾城市,但是當我嘗試調試它時,我遇到了一些奇怪的情況,即 StateId 為空。有誰可以幫助我嗎?謝謝。   [HttpPost]       public async Task<JsonResult> GetCities(DataSourceRequest request, CancellationToken cancellationToken = default)        {            request.Skip = 0;            request.Take = 2000;            var city = await _cityService.GetCities(request, cancellationToken);            return Json(city);        }正如你所看到的,該值為 null,這是我的 jquery 代碼部分... $("#drpState").kendoDropDownList({                optionLabel: "States...",                delay: 10,                dataTextField: "Name",                dataValueField: "StateId",                dataSource: {                    type: "json",                    serverFiltering: true,                    transport: {                        read: {                            headers: {                                "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val()                            },                            type: "Post",                            dataType: "json",                            url: "/Supervision/Tracking/GetStates",                        }                    },                    schema: { data: 'Data' }                },            }).data("kendoDropDownList");
查看完整描述

1 回答

?
開滿天機

TA貢獻1786條經驗 獲得超13個贊

當我嘗試調試它時,我遇到了一些奇怪的事情,即 StateId 為空。

我使用Kendo UI jQuery DropDownList和 ASP.NET Core WebAPI 作為后端服務進行了測試,我可以重現相同的問題。

基于JS客戶端發出的請求的formdata,為了使ASP.NET Core端點能夠很好地接受和處理這些數據,您可以嘗試以下解決方法。

自定義模型類

public class DataSourceRequestForCore

{

? ? public int Take { get; set; }

? ? public int Skip { get; set; }

? ? public FilterForCore filter { get; set; }

}


public class FilterForCore

{

? ? public string logic { get; set; }

? ? public List<FilterEntry> filters { get; set; }

}


public class FilterEntry

{

? ? [DataMember(Name = "field")]

? ? public string Field { get; set; }


? ? [DataMember(Name = "operator")]

? ? public string Operator { get; set; }


? ? [DataMember(Name = "value")]

? ? public string Value { get; set; }

}

動作方法


[HttpPost]

public async Task<JsonResult> GetCities(DataSourceRequestForCore request, CancellationToken cancellationToken = default)

{

? ? request.Skip = 0;

? ? request.Take = 2000;


? ? //....

? ? //code logic here

測試結果

https://img4.sycdn.imooc.com/64c4cc8b00014d8010790218.jpg


查看完整回答
反對 回復 2023-07-29
  • 1 回答
  • 0 關注
  • 162 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號