简体   繁体   English

将Telerik ASP.NET Ajax RadGrid加载到模式弹出窗口中,并通过Ajax刷新数据而无需页面刷新

[英]Load a Telerik ASP.NET Ajax RadGrid into a Modal Popup and Refresh Data Over Ajax without Page Refresh

I have an application which currently implements a dynamically created RadGrid. 我有一个当前实现动态创建的 RadGrid的应用程序。 The grid is generated by reading the columns and datatypes from a specific SQL Server View. 通过从特定的SQL Server视图读取列和数据类型来生成网格。 We have many of these views which is why we use Dynamic creation. 我们有许多这样的视图,这就是为什么我们使用动态创建。

Every time the user interacts with a grid control (eg filter/paging control), the entire page is refreshed. 每次用户与网格控件(例如,过滤器/分页控件)进行交互时,都会刷新整个页面。 The RadGrid is recreated from scratch in the Page_PreInit method and populated with the updated data. Page_PreInit方法中从头开始重新创建Page_PreInit并使用更新的数据填充。 This is a very poor user experience and also draining on server resources. 这是非常差的用户体验,并且还会消耗服务器资源。

I'm trawling through the Telerik documentation and cannot find a clear example of what I'm trying to achieve. 我正在浏览Telerik文档,但是找不到我想要实现的清晰示例。 I'd like to know if it's possible to achieve the following requirements: 我想知道是否有可能达到以下要求:

  1. Clicking on a link on a page will load a Telerik Modal Window Popup. 单击页面上的链接将加载Telerik Modal窗口弹出窗口。
  2. The contents of the Modal popup are retrieved by Ajax POST request to the server - this will create the initial dynamic grid and return HTML contenttype. 通过对服务器的Ajax POST请求检索Modal弹出窗口的内容-这将创建初始动态网格并返回HTML contenttype。
  3. Once loaded into the modal popup, the grid HTML structure becomes dynamic and only the updated data from a paging or filtering operation is returned from the server when the event fires - preferably JSON only is sent to reduce bandwidth overheads of transporting HTML. 一旦加载到模式弹出窗口中,网格HTML结构将变为动态状态,并且在事件触发时仅从服务器返回来自分页或过滤操作的更新数据-最好仅发送JSON以减少传输HTML的带宽开销。

Can this use case be achieved with Telerik UI for ASP.NET Ajax? 可以使用用于ASP.NET Ajax的Telerik UI来实现此用例吗?

  1. You can, here is how to open a RadWindow: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/getting-started/opening-windows . 您可以通过以下方法打开RadWindow: http ://docs.telerik.com/devtools/aspnet-ajax/controls/window/getting-started/opening-windows。 Basically, call its show() client-side method. 基本上,调用其show()客户端方法。

  2. The easiest way to do this is to have an aspx page that will render your grid and open it in the RadWindow (see the NavigateUrl property and the setUrl() client-side method, and the first argument to radopen() or open()). 最简单的方法是拥有一个aspx页面,该页面将呈现您的网格并在RadWindow中打开它(请参见NavigateUrl属性和setUrl()客户端方法,以及radopen()或open()的第一个参数) )。 RadWindow will generate a GET request for that page. RadWindow将为该页面生成一个GET请求。

Option 2: Use the OnClientShow event of the RadWindow to generate your POST (eg, via the __doPostBack() MS AJAX function) and use the ContentTemplate of the RadWindow. 选项2:使用RadWindow的OnClientShow事件生成POST(例如,通过__doPostBack()MS AJAX函数)并使用RadWindow的ContentTemplate。 Examine the following article to see how to use AJAX with it: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/how-to-use-radwindow-with-ajax . 请检查以下文章,以了解如何将AJAX与之配合使用: http : //docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/how-to-use-radwindow-with-ajax

  1. This is autmatically achieved by the first option from the second point - the content page will encapsulate its own requests. 这是通过第二点的第一个选项自动完成的-内容页面将封装自己的请求。 Proper AJAX setup in Option2 will give you the same but the grid will reside on your main page. 在Option2中正确的AJAX设置将为您提供相同的设置,但网格将位于您的主页上。

Hint: Generally postbacks are used to fetch the data. 提示:通常,回发用于获取数据。 If you want less than that, use client-side binding for your grid: http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx 如果您不希望这样做,请对网格使用客户端绑定: http : //demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/ defaultcs.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM