为什么CascadeFrom()什么都不做? [英] Why is CascadeFrom() not doing anything?

查看:302
本文介绍了为什么CascadeFrom()什么都不做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是真正的新剑道UI和我在与 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
<select id="Testing">
    <option value="0">Vehicle</option>
    <option value="1">Driver</option>
    <option value="2">Trailer</option>
</select>

// 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?

修改:我已经试过下面Petur的解决方案,通过改变父下拉菜单以下内容:

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?

控制器操作签名:

public JsonResult GetVDT(CompanyUnavailabilityType type)

其中, CompanyUnavailabilityType 是一个枚举。

推荐答案

这两个Petur和C沙坡在正确的轨道的问题上。

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


  1. 我确实需要使用建立下拉 Html.Kendo.DropDownList()(我得到解决后,工作刚刚验证了这一点。)

  2. 控制器上的方法签名是一个问题,但只是因为我喝了留在旧有检测方法,导致模棱两可的电话。

  1. I did need to build the dropdown using Html.Kendo.DropDownList() (I've just verified this after getting the solution to work.)
  2. 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.

对于我来说,最大的困难是,没有什么是被报道在调试器,所以诊断问题是一个痛苦。最后,我用的Firefox网页开发工具网络选项卡,以保证确实正在发送的Ajax请求,这是。检查这一要求表明,它是导致控制器上的暧昧电话。

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.

此外,清理从C更清晰的答复意见:

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


  1. 则不需要 parseInt函数()电话。

  2. 通话将正确映射到服务器端的枚举,这意味着我张贴在我的问题的方法签名是正确的。

这篇关于为什么CascadeFrom()什么都不做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆