客户端 JavaScript 或服务器端

发布于 2024-12-05 03:13:01 字数 411 浏览 2 评论 0原文

我有一个报告页面,可以根据某些条件过滤客户并在浏览器上显示他们的详细信息。如果客户的注册日期在某个日期(例如 2011 年 1 月 1 日)之后,我需要用不同的颜色突出显示该日期。我想知道执行此操作的最佳方法是什么,因为有大约 800 条记录需要显示。

  • 如果我检查客户端的日期 - javascript,我会检查并将其与每条记录的特定日期进行比较,这会大大减慢处理速度

  • 如果我在服务器端运行计划脚本并在数据库中设置一个标志来指示将设置的错误记录显示的颜色,我该如何做到这一点一种对于记录的其他字段可扩展的方式??

更新

感谢您的精彩回答。因此,如果我想扩展它以包括记录的所有字段,是否可以在单独的表中为每个字段存储一个标志,然后检查该表以查看为每个记录设置了哪些标志并相应地更改显示??

I have a report page that filters customers based on some criteria and displays their details on the browser. If the registration date of the customer is after a certain date say 1st January 2011, I need to highlight the date in a different color. I am wondering what is the best way to do this as there are around 800 records to display.

  • if i check the date on the client side - javascript , i would be checking and comparing it with the certain date for each record which would slow down processing a lot

  • if i run a scheduled script on the server side and set a flag in the database to indicate erroneous records which will set the color on display, how can i do this in a way which is scalable for other fields of the record??

UPDATE

Thanks for the great answers. So if I want to scale this to include all the fields of the record, would it be right to store a flag for each field in a separate table and then check the table to see which flags are set for each record and accordingly change the display??

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

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

发布评论

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

评论(1

飘逸的'云 2024-12-12 03:13:01

在情况 2 中,当您在服务器端标记记录时,如果您使用 JSP 和 JSTL-Tag 库,则可以像这样完成输出:

警告:未经测试

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach items="${customerList}" var="customer" varStatus="status">
    <c:if test="${status.first}">
        List of Customers:<br>
        <ul>
    </c:if>
            <li <c:if test="${customer.flag}">class="marked"</c:if>>
               <c:out value="${customer.name}"/>
            </li>
    <c:if test="${status.last}">
       </ul>
    </c:if>
</c:forEach>

如果您想根据以下内容标记条目其他记录,那么您必须调整设置标志的脚本。

In case 2, when you mark your records on the server side, output can be done like that if you are using JSPs and the JSTL-Tag library:

Warning: UNTESTED

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:forEach items="${customerList}" var="customer" varStatus="status">
    <c:if test="${status.first}">
        List of Customers:<br>
        <ul>
    </c:if>
            <li <c:if test="${customer.flag}">class="marked"</c:if>>
               <c:out value="${customer.name}"/>
            </li>
    <c:if test="${status.last}">
       </ul>
    </c:if>
</c:forEach>

If you want to mark entries depending on other records, then you have do adapt the script that sets the flag.

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