如何通过 Telerik MVC Grid Ajax 插入/更新/删除向客户端发送自定义错误消息?

发布于 2024-10-01 09:21:32 字数 154 浏览 0 评论 0原文

我正在 Telerik Grid 扩展中使用 Ajax 编辑。我想处理插入/更新/删除上的错误/异常,并在显示回客户端的消息框中显示用户友好的消息,而不是默认消息“错误!请求的 URL 返回 500 - 内部服务器错误” ”或类似的内容。

有没有办法告诉网格显示自定义文本消息?

I am working with Ajax Editing within a Telerik Grid extension. I would like to handle errors/exceptions on Insert/Update/Delete and display a user friendly message in the message box that is displayed back to the client, instead of the default message of "Error! The requested URL returned 500 - Internal Server Error" or the like.

Is there a way to tell the grid to display a custom text message?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

欢你一世 2024-10-08 09:21:32

有人在这里定制了警报:http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-return-error-information-to-grid-in-ajax-editing -mode.aspx,但我仍在寻找一种方法来实际更新网格本身...

客户端网格的 noRecordsTemplate 属性有一点希望,但我们仍然需要一种方法来清除网格可能已经存在的任何记录。

编辑:

找到它:要清除网格并设置消息,请执行以下操作:

var grid = $('#Grid').data('tGrid');
grid.total = 0;
grid.dataBind(Array());
$('#Grid').find('.t-no-data td').text('My Custom Error Message');

当然,您可以自己弄清楚如何将我的示例与上面链接中的示例结合起来。

Someone customized the alert here: http://www.telerik.com/community/forums/aspnet-mvc/grid/how-to-return-error-information-to-grid-in-ajax-editing-mode.aspx, but I'm still searching for a way to actually update the grid itself...

There's a little hope in the client-side grid's noRecordsTemplate property, but we still need a way to clear the grid of any records that may have already been there.

Edit:

Found it: To clear the grid, and set your message, do the following:

var grid = $('#Grid').data('tGrid');
grid.total = 0;
grid.dataBind(Array());
$('#Grid').find('.t-no-data td').text('My Custom Error Message');

Of course, you can figure out on your own how to combine the my example and the example from the link above.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文