2014-10-28 34 views
1

我有一个Kendo DropDownList,我想通过javascript函数更新/刷新。使用FireFox和Chrome,它工作正常,但与Internet Explorer,它不会更新任何东西。使用Internet Explorer更新Kendo DropDownList

@(Html.Kendo().DropDownList() 
    .Name("myDDL") 
    .HtmlAttributes(new { style = "width: 320px" }) 
    .DataTextField("Description") 
    .DataValueField("Id") 
    .DataSource(source => 
    { 
     source.Read(read => 
     { 
      read.Action("fillDDL", "ControllerName"); 
     }); 
    }) 
) 

JavaScript函数:

function refreshForm() { 
    $("#myDDL").data("kendoDropDownList").dataSource.read(); 
} 

而且还检查this question,但没有运气。

我使用Internet Explorer 11进行测试。

任何帮助?

编辑

这是生成的Javascript代码:

jQuery(function() { 
    jQuery("#myDDL").kendoDropDownList({ 
     "dataSource": { 
      "transport": { 
       "read": { 
        "url": "/ControllerName/fillDDL" 
       }, 
       "prefix": "" 
      }, 
      "schema": { 
       "errors": "Errors" 
      } 
     }, 
     "dataTextField": "Description", 
     "dataValueField": "Id" 
    }); 
}); 
+0

你的第一个调用'dataSource.read'的函数看起来是正确的。它在调用时是否发出服务器请求来加载新数据?你可以包含从MVC助手生成的JavaScript? – CodingWithSpike 2014-10-28 17:03:01

+0

@CodingWithSpike,检查我的编辑 – chiapa 2014-10-28 17:12:31

+0

除了ID不同('优惠'vs'myDDL'),你的代码看起来是正确的。你对'dataSource.read()'的调用是否会向URL“/ ControllerName/fillDDL”发出一个请求? – CodingWithSpike 2014-10-28 17:40:23

回答

1

我找到了一个解决方案,我张贴,以便它可以帮助其他人谁也面临同样的问题。

现在我有

read.Action("fillDDL", "ControllerName").Type(HttpVerbs.Post); 

,而不是

read.Action("fillDDL", "ControllerName"); 

添加这段代码现在允许的DropDownList被刷新,使用Internet Explorer时也是如此。

相关问题