Gridview 和查看的项目
我有一个 gridview (DXperience gridview),我想在其中显示用户是否已单击该行中的链接。 每行上的链接会将用户发送到一个页面,其中显示有关该项目的更多详细信息。 为了象征这一点,我想到了例如将访问的行的背景设置为不同的颜色。
我的问题是最简单、最有效的方法是什么?
我的想法: 由于没有登录系统,我考虑将项目的 ID 保存在以逗号分隔的 cookie 中,并且在渲染行时,我将在 cookie 中查看该项目是否已被查看。
我担心这会使网格视图变得多慢。 我通常会显示几千行,如果用户单击了大约 40 个项目,则需要一段时间才能浏览每行上的 40 个项目,以检查它是否已被查看。 这是一个合理的担忧吗?如果是,我该如何优化它?
I have a gridview (DXperience gridview) where I would like to display if the user has already clicked on a link in that row. The link on each row sends the user to a page where more detail is shown about the item. To symbolize this I have thought of e.g. making the background of the visited rows in a different colour.
My question is what is the easiest and most efficient way to do this?
My Idea:
Since there is no login system I have thought of saving the IDs of the items in a cookie seperated by comma, and when rendering the rows I will look in the cookie to see if that item is already viewed.
I have a concern on how slow this will make the gridview. I am usually displaying a few thousand rows and if the user has clicked on maybe 40 items, it will take a while to run through 40 items on each row, to check if it is already viewed. Is this a valid concern, and if yes, how could I optimize it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法可以做到这一点。 使用 cookie 是一种有效的方法,尽管它可能不允许干净地使用 :visited。
此人在绑定时更改了地址,因此它与唯一 ID 匹配。 链接 他们在着色方面遇到了问题IE7; 我怀疑这是因为他们必须使用锚点(#)。
更新:
根据您的情况,您可以尝试将行 ID 列表传递给文字:
传入 JS 数组,您可以循环遍历它并以这种方式设置行颜色。 它的开销并不是特别高,至少在您访问了数百个链接之前不会。
您还可以在行绑定期间在服务器端执行此操作。 根据服务器与客户端负载的不同,这可能是更好的选择。
(我是凭记忆工作,在工作中不使用 C#,但您已经了解了总体思路。)
There are a couple of ways you could do it. Using the cookie is one valid way, though it will probably not allow for a clean use of :visited.
This person changed the address on binding, so it matches to a unique ID. link They had a problem with coloring in IE7; I suspect this is because they had to use an anchor (#).
Update:
Depending on your situation you could try passing a list of row IDs to a literal:
Pass in a JS array and you can loop through it and set the row colors that way. It's not especially high overhead, at least not until you get past a few hundred links visited.
You can also do this on the server side, during row bind. Depending on server vs. client load, this may be the better option.
(I'm working from memory and don't use C# at work, but you get the general idea.)