简体   繁体   中英

client side javascript or server side

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??

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM