cascade down_为什么CascadeFrom()什么都不做?

I'm really new to Kendo UI, and I'm having problems with CascadeFrom() not calling an action on my controller. Here's the bare bones of my problem:

// The parent dropdown

Vehicle

Driver

Trailer

// The dynamic dropdown

@(Html.Kendo().DropDownListFor(m => m.VDTId)

.DataValueField("Id")

.DataTextField("Item")

.DataSource(ds =>

{

ds.Read(c => c.Action("GetVDT", "CompanyVDTUnavailability")

.Data("getVDTSelection"))

.ServerFiltering(true);

})

.CascadeFrom("Testing"))

// Function to allow Kendo to pass a value to

// the type parameter of my GetVDT action.

function getVDTSelection() {

return {

type: parseInt($("#Testing").val())

};

}

The action is being called when the page first loads, and returns the correct data. The problem is, if I then make a selection from the Testing dropdown, the action is never invoked on the controller (I've verified this using a breakpoint on the action), meaning the dynamic dropdown never gets updated.

Looking through the official example, and other questions around SO, I can't see what I'm doing wrong. Could someone point me in the right direction, please?

Edit: I've tried Petur's solution below by changing the parent dropdown to the following:

@(Html.Kendo().DropDownListFor(m => m.Type)

.Name("Testing")

.DataValueField("Id")

.DataTextField("Text")

.BindTo(Model.UnavailabilityTypes))

This binds the parent dropdown correctly, but no longer invokes the controller action for the cascading dropdown even when the page first loads. Any suggestions?

Controller action signature as requested:

public JsonResult GetVDT(CompanyUnavailabilityType type)

Where CompanyUnavailabilityType is an enum.

解决方案

Both Petur and C Sharper were on the right track with the problem.

I did need to build the dropdown using Html.Kendo.DropDownList() (I've just verified this after getting the solution to work.)

The method signature on the controller was a problem, but only because I'd had old testing methods left on there, leading to an ambiguous call.

The major difficulty for me was that nothing was being reported in the debugger, so diagnosing the problem was a pain. In the end, I used the Network tab of the Firefox web developer tools to ensure the Ajax request was indeed being sent, and it was. Inspecting that request showed it was leading to an ambiguous call on the controller.

Also, to clear up comments from C Sharper's answer:

The parseInt() call is not required.

The call will correctly map to an enum on the server-side, meaning the method signature I posted in my question is correct.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值