Change the background of a row based on date comparison

Comments

5 comments

  • Official comment
    Avatar
    Thomas Morin

    Hello Aaron,

    I created a ticket because it will be easier to discuss with you.

    Kind regards.

    Thomas

    Comment actions Permalink
  • Avatar
    Nicolas Gauvin

    Hello,

    There are unfortunately no native ways to achieve this.

    If you are familiar with Javascript this can be achieved with a javascript template.

    Nicolas

    0
    Comment actions Permalink
  • Avatar
    Aaron Schoon

    I figured it would need to be done through javascript.  For starters, I put a function in the <script> section to just generate the current date.  The code works outside of awesome table, but not within. Why is that?

     

    Also, does the javascript execute for each row, or just in the beginning?

     

    It seems like there is minimal documentation available on javascript use with awesome tables.

    0
    Comment actions Permalink
  • Avatar
    Nicolas Gauvin

    Hello,

    There are no "Awesome Table specific" rules on using Javascript. Could you give me a snapshot of your code?

    The code in "<script>" only runs once, when data is loaded.

    Unfortunately, we are completely reworking our documentation on templates for the moment, so there are not a lot of documentation on the matter. Sorry about the inconvenience.

    Regards,

    Nicolas

    0
    Comment actions Permalink
  • Avatar
    Aaron Schoon

    HTML:
    <body onload='return my_curr_date();'>
    <input type='text' name='dateField' id='dateField' value='' />
    </body>

     

    <script>

    function my_curr_date() {
    var currentDate = new Date()
    var day = currentDate.getDate();
    var month = currentDate.getMonth() + 1;
    var year = currentDate.getFullYear();
    var my_date = month+"-"+day+"-"+year;
    document.getElementById("dateField").value=my_date;
    }

     

    0
    Comment actions Permalink

Please sign in to leave a comment.