确定 Telerik MVC Grid 的所选项目和当前页面 - 客户端
我正在使用带有 Ajax 数据绑定的 Telerik MVC 网格。
我想用 Telerik MVC 网格做两件事:
- 当选择一行时,检测(客户端)网格当前位于哪个页面以及选择了哪一行。
- 下次加载网格时(使用ajax ...我从不离开页面),页面返回到同一页面以显示最后的选择。 (我想我实际上只是在问是否有一种方法可以在数据加载后立即转到网格页面,而不是第 1 页)
请记住,我已经知道客户端事件。我想知道如何从事件中执行#1,以及如何从客户端或以编程方式执行#2。
编辑/更多详细信息:我想我知道我需要在这里做什么。由于我在这里使用 Ajax 加载,因此在 Telerik 代码中的某处调用了 Ajax POST。我可以看到,在 Ajax POST 期间,它们正在向控制器发送一个“page”参数。如果我可以以某种方式编辑它,我确信它会起作用 - 但我在更改该参数时遇到了麻烦。
提前致谢!
I am using the Telerik MVC grid, with Ajax data binding.
I would like to do 2 things with the Telerik MVC Grid:
- When a row is selected, detect (client side) which page the grid is currently on as well as which row was selected.
- The next time the grid is loaded (using ajax ... I never leave the page), page back to the same page to show the last select. (I guess I am really just asking if there is a way to immediately go to a page of the grid once the data is loaded, rather than page 1)
Please keep in mind, I am aware of the client side events already. I would like to know how to do #1 from the event, and #2 either from the client side or programatically somehow.
Edit/More Details: I think I know what I need to do here. Since I am using Ajax loading here, the Ajax POST is being called somewhere in the Telerik code. I can see that during that Ajax POST they are sending a "page" parameter to the controller. If I could edit that somehow, I am sure it would work - but I am having trouble changing that parameter.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了其他人寻找这个,我想通了:
获取网格的当前页面:
为此,我使用 jQuery 来确定哪个数字具有“选定”样式(t-state-active)来确定当前页码。示例(我的网格 ID 是“cases-grid”):
我的问题的第二部分实际上在 Telerik 网站上有详细记录......我只是错过了一段时间。要将网格加载到特定页面(1 除外),我将以下内容添加到我的网格中:
并将 InitialPage 属性添加到我的模型中。
For the sake of anyone else looking for this, I figured it out:
Getting the current page of the Grid:
To do this, I use jQuery to determine which number has the "selected" style (t-state-active) to determine the current page number. Example (my grid id is 'cases-grid'):
The second part of my question was actually well documented on the Telerik site ... I just missed it for awhile. To load the grid to a specific page (other than 1) I added the following to my grid:
And added the InitialPage property to my model.