带有 ASP.NET gridview 的 Tablesorter 插件
当使用这两个家伙时,我得到了奇怪的结果,因为它只对正在查看的页面进行排序,而我还需要对分页进行排序。其次,当分页数字出现时,asc 和 desc 效果会将数字放在顶部或底部。最后但并非最不重要的一点是,网格位于更新面板内,当我尝试第二次单击用于排序的标题时,只有当我按下 Shift 按钮时,才会发生任何事情。
I'm having strange results when using this two fellows because it only sort the page is viewing and I need to sort across pagination as well. Second, when the pagination numbers appear the asc and desc effects put the numbers on top or at the bottom. And last but not least, the grid is inside an updatepanel and when I try to click for a second time the header for sorting nothing happens, only if I press the shift button.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
分页是发生在客户端还是服务器端?听起来像是服务器端的。如果是这种情况,那么 jQuery 插件无法对页面上的内容进行排序,因为从 JavaScript(客户端)的角度来看,有除页面上的记录外,没有其他记录。
表格单元格中的数字与表格的其他部分一样吗?它们与其他行有什么区别吗?听起来 jQuery 插件只是对表进行排序,而不管表的内容如何。渲染表格的服务器端代码不了解 jQuery 插件,也无意迎合它。
对于您正在寻找的更动态的客户端表操作,我强烈建议使用类似 jqGrid。它在内部处理诸如分页和排序之类的事情,因此您不必担心在相互排斥的插件/控件/框架之间手动协调客户端和服务器端代码。
与使用服务器端网格控件相比,这是一个相当重大的转变,因此不要将其视为直接替代品。但是,能够有效地使用它将为您提供许多 AJAX 友好的客户端交互选项。要记住的主要事情是在服务器端代码和客户端代码之间有清晰的界限。有一个单独的服务器端处理程序来响应 AJAX 请求,并将其视为客户端 JavaScript 使用的“Web 服务”。
Is the pagination happening client-side or server-side? It sounds like it's server-side. If that's the case, then the jQuery plugin can't sort anything more than what's on the page, because from the perspective of JavaScript (which is client-side) there are no other records than the ones on the page.
Are the numbers in table cells like the rest of the table? Are they differentiated from the other rows in any way? It sounds like the jQuery plugin is just sorting the table, regardless of the table's contents. The server-side code which is rendering the table has no knowledge of the jQuery plugin and has no intention of catering to it.
For the more dynamic client-side table manipulation that you're looking for, I highly recommend using something like jqGrid. It internally handles things like paging and sorting, so you wouldn't have to worry about reconciling your client-side and server-side code manually between otherwise mutually exclusive plugins/controls/frameworks.
It's a fairly significant shift from using server-side grid controls, so don't think of it as a drop-in replacement. But being able to effectively use it will give you a lot of options for AJAX-friendly client-side interactions. The main thing to keep in mind is to have a clear line of separation between the server-side code and the client-side code. Have a separate server-side handler for responding to AJAX requests and treat it like a "web service" used by the client-side JavaScript.