Javascript 剑道刷新(DropDownList.refresh())不工作错误未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12132939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 07:11:13  来源:igfitidea点击:

Kendo Refresh (DropDownList.refresh()) not working ERROR Not define

javascriptjqueryasp.nettelerikkendo-ui

提问by cwishva

Im trying to refresh the Drop Down List after another DropDownList is Change But the Refresh() method is Undefined Error Is Promoting.There For I Tried the Read the DataSource again and it shows it loading but the data is still the same.Help to Solve this Issue please.

我试图在另一个 DropDownList 更改后刷新下拉列表,但 Refresh() 方法是未定义的错误正在提升。因为我再次尝试读取数据源,它显示它正在加载但数据仍然相同。帮助解决这个问题请。

Code:

代码:

$("#DropDownList1").change(function () {
   custCode = $("#DropDownList1").val();

   $("#titles").data("kendoDropDownList").dataSource.read(); //shows list Loading But Same Data Is present .
   $("#titles").data("kendoDropDownList").refresh(); //NOT Working 

});

回答by Abhishek

1- Try adding cache: falseto disable the cache in Kendo DropDownList's datasource read property:

1- 尝试cache: false在 Kendo DropDownList 的数据源读取属性中添加禁用缓存:

read: {
    url: <<"url">>,
    cache: false
}

2- Then call read(),

2-然后打电话read()

$("#ddl").data("kendoDropDownList").dataSource.read();

It worked for me :)

它对我有用:)

回答by user1291282

For me just this line did the job:

对我来说,这条线完成了这项工作:

$("#myDropDownList").data("kendoDropDownList").dataSource.read();

$("#myDropDownList").data("kendoDropDownList").dataSource.read();

回答by Houdini Sutherland

You might find passing parameters to the ".data()" of the dataSource useful.

您可能会发现将参数传递给 dataSource 的“.data()”很有用。

Example:

例子:

var myDataSource={bookId: 10, Name: "Kendo"}
$("#titles").data("kendoDropDownList").dataSource.data(myDataSource);

However, you could also try the cascadingFromattribute of the DropDownList when you want to update one DropDownList based on the selection of another DropDownList

但是,当您想根据另一个 DropDownList 的选择更新一个 DropDownList 时,您也可以尝试DropDownList的cascadingFrom属性

//Houdini

//胡迪尼

回答by John Dover

on your read url add '?myDate=' + new Date(). This will refresh the data. Without it (unless you have meta tags to prevent caching) it will give you that data it has already read.

在您阅读的网址上添加 '?myDate=' + new Date()。这将刷新数据。没有它(除非你有元标记来防止缓存)它会给你它已经读取的数据。

回答by Juan Camilo Zapata

In my case I commented the line

就我而言,我评论了这一行

//cascadeFrom: "dropdown1_id"

on the second kendo dropdown and it worked, for some reason it was messing with the data source updates.

在第二个 kendo 下拉菜单中它起作用了,由于某种原因,它弄乱了数据源更新。