Telerik MVC Grid 客户端 .dataBind() 抛出异常
当我尝试调用 .dataBind() 在 JavaScript 中的 Telerik Grid 对象上,它会引发异常。我使用的相同代码在以前版本的 Telerik 控件 (2010.2.930) 上运行得很好,但自从更新(使用 NuGet)到最新版本 (2011.2.712) 后,代码已损坏。
这些是不同浏览器上的各种错误。
Firefox 6: this.dataSource 未定义(telerik.grid.min.js - 第 1 行)
Chrome 13:未捕获类型错误:无法调用未定义的“成功”方法 (telerik.grid.min.js:1)
IE 9: SCRIPT5007:无法获取属性“成功”的值:对象为空或未定义(telerik.grid.min.js,第1行字符25697)
我成功创建了一个非常简单的存储库,您所需要做的就是将其放在一个新页面中:
<div>
@(Html.Telerik().Grid(new List<GridData>())
.Name("TestGrid")
.Columns(column =>
{
column.Bound(e => e.Name).Title("Name").Width("9em");
column.Bound(e => e.Description).Title("Description").Width("9em");
}))
</div>
<p>
<a id="getData" href="#">Bind Data</a>
</p>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$('#getData').click(bindGridData);
});
})(jQuery);
var bindGridData = function() {
var grid = $("#TestGrid").data("tGrid");
var testData = [
{ Name: "Name 1", Description: "Description 1" },
{ Name: "Name 2", Description: "Description 2" }
];
grid.dataBind(testData);
};
</script>
GridData 类只是一个带有 Name 和 Description 字符串属性的简单 POCO。
When I try and call .dataBind() on a Telerik Grid object in javascript, it throws an exception. The same code I'm using was working just fine with a previous version of the Telerik controls (2010.2.930) but since the update (using NuGet) to the latest version (2011.2.712), the code has broken.
These are the various errors on different browsers.
Firefox 6: this.dataSource is undefined (telerik.grid.min.js - line 1)
Chrome 13: Uncaught TypeError: Cannot call method 'success' of undefined (telerik.grid.min.js:1)
IE 9: SCRIPT5007: Unable to get value of the property 'success': object is null or undefined (telerik.grid.min.js, line 1 character 25697)
I have managed to create a very simple repo, all you need to do is put this in a fresh page:
<div>
@(Html.Telerik().Grid(new List<GridData>())
.Name("TestGrid")
.Columns(column =>
{
column.Bound(e => e.Name).Title("Name").Width("9em");
column.Bound(e => e.Description).Title("Description").Width("9em");
}))
</div>
<p>
<a id="getData" href="#">Bind Data</a>
</p>
<script type="text/javascript">
(function ($) {
$(document).ready(function () {
$('#getData').click(bindGridData);
});
})(jQuery);
var bindGridData = function() {
var grid = $("#TestGrid").data("tGrid");
var testData = [
{ Name: "Name 1", Description: "Description 1" },
{ Name: "Name 2", Description: "Description 2" }
];
grid.dataBind(testData);
};
</script>
The GridData class is just a simple POCO with Name and Description string properties.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这是他们代码中的一个错误。我向 Telerik 发出了支持票,他们给了我一个修补程序。
不幸的是,我无法链接到它,因为它是私人消息。但是,不要害怕,我确实设法在公共论坛页面上找到了它的链接:
http://www.telerik.com/community/forums /aspnet-mvc/general/gridroutevalues-allowhtml.aspx
如果这不起作用,您可以随时等待,直到它在下一个 NuGet drop 中修复。
Seems like it was a bug in their code. I issued a support ticket with Telerik and they gave me a hotfix.
Unfortunately I can't link to it because it's a private message. BUT, don't fear, I did manage to find a link to it on a public forum page:
http://www.telerik.com/community/forums/aspnet-mvc/general/gridroutevalues-allowhtml.aspx
If that doesn't work you can always wait until it's fixed in the next NuGet drop.