telerik radGrid - 在排序/分页/过滤器上保留客户端状态

发布于 2024-11-08 19:44:27 字数 955 浏览 3 评论 0 原文

即使在这个 ajax 示例 我真的很喜欢它的外观,当顶级网格被排序时,你正在做的事情的“状态”就会“消失”,

例如,

打开第一个人的行 (Nancy Davolio),以便您可以看到销售网格

在销售网格中按订单总计排序

在顶级网格中按出生日期排序

南希·达沃伊洛 (Nancy Davoilo) 现在应该排名第二。打开她的行。

销售网格不再按订单总额排序

这可能看起来微不足道,或者说我很挑剔;但是:

如果我在销售网格上有一些文本框(或接受用户输入的其他类型的方法),我会假设在对顶级网格进行排序时这会被破坏。 我还认为,即使我在顶级网格上有此输入,对顶级网格进行排序(或如果有过滤器则进行过滤)也会破坏此输入。

看来即使分页也破坏了这一点。

所需的行为是排序和分页不仅“看起来”在客户端完成,因为它使用 ajax 请求,而且实际上是在客户端完成。这意味着网格的实际行在客户端按字面意思排序(过滤、分页等),以便任何客户端更改,例如向文本框添加文本、向对象添加 css 类,[或者以更复杂的方式例如,通过 Jquery 将 javascript 对象的引用添加到对象: $("#div1").data("object",someObject) 将在排序、分页和过滤后保留。

有办法实现这一点吗?

我是否清楚地表达了我想要做的事情?如果没有,我很乐意澄清。

附加说明:我认为只要没有大量的行,执行此类操作对客户端性能的影响就会很小。事实上,服务器上重新创建所有记录、重复调用服务器/数据库的工作量会减少很多,并且如我在顶部的示例所示,子页面只需要创建一次而不是两次。

Even in this ajax example
which I really like the look of, when ever the top level grid is sorted the "state" of what you were doing "disappears"

For example,

Open the first person's row (Nancy Davolio) so you can see the Sales grid

Sort by Order Total in the Sales grid

Sort by Birth Date in the top level grid

Nancy Davoilo should now be second. Open her row.

The sales grid is no longer sorted by Order Total

This may seem trivial, or that i'm being picky; However:

If I have some text box(or some other type of method of accepting user input) on the sales grid, I would assume that this would get destroyed when sorting the top level grid.
I would also think that even if I had this input on the top level grid, that sorting the top level grid (or filtering if there were filters) would destroy this input.

It seems that even paging destroys this.

The desired behavior would be for sorting and paging not just "appear" to be done client side because it's using an ajax request, but to ACTUALLY be done client side. Meaning that the actual rows of the grid are literally sorted(filtered, paged, etc.) client side so that any client side changes such as adding text to a text box, adding a css class to an object, [or in a more complex example adding a reference to a javascript object to an object via Jquery: $("#div1").data("object",someObject) would persist after sorting, paging and filtering.

Is there a way to make this happen?

Am I making what i'm looking to do clear? If not i'm happy to clarify.

Additional Notes: I would think the client side performance hit would be minimal to do something like this as long as there were not a very large number of rows. In fact there would be a lot less work on the server in recreating all of the records, repeated calls to the server/database and as in my example at the top the subPages would only need to be created once rather than twice.

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

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

发布评论

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

评论(2

肥爪爪 2024-11-15 19:44:28

看一下 MasterTableView 的 HierarchyLoadMode 属性。您引用的演示使用的是 HierarchyLoadMode.ServerOnDemand,根据 Telerik 的文档,意味着 ViewState 只维护可见项的状态。因此,当详细信息网格折叠时,您将丢失其状态(例如排序顺序、页码等)。

还有其他模式。您可以选择 HierarchyLoadMode.ServerBind 它维护所有详细信息表的 ViewState,但需要 PostBack 来展开详细信息表。 HierarchyLoadMode.Client 呈现 MasterTableView,所有 DetailTables 和项目都在客户端上展开/折叠 - 不需要 PostBack。这些模式中的任何一种还应该维护与详细表相关的排序顺序和其他状态。

我希望这有助于回答您的问题。

Take a look at the HierarchyLoadMode property of the MasterTableView. The demo you reference is using HierarchyLoadMode.ServerOnDemand which, according to Telerik's documentation, means that ViewState only maintains the state of the visible items. Therefore, when a details grid is collapsed you will lose its state (e.g. a sort order, page number, etc).

There are other modes. You can choose HierarchyLoadMode.ServerBind which maintains ViewState for all detail tables but requires a PostBack to expand a detail table. The HierarchyLoadMode.Client renders the MasterTableView and all DetailTables and items are expanded/collapsed on the client - no PostBack required. Either of those modes should also maintain the sort order and other state related to the detail tables.

I hope that helps answer your question.

面如桃花 2024-11-15 19:44:28

我最近收到 Telerik 支持人员的回复,他们的 AJAX 网格支持开箱即用的客户端绑定,仅使用平面结构进行排序、分页和过滤(如 此演示)。

对于您的情况,您可能有两个选择:

I recently got a reply from the Telerik support that their AJAX grid supports client binding out-of-the-box with sorting, paging and filtering with flat structure only (as in this demo).

For your case you may have two options:

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