Javascript in SmartNote Template

 2 Replies
 0 Subscribed to this topic
 14 Subscribed to this forum
Sort:
Author
Messages
Randall
Veteran Member
Posts: 44
Veteran Member
    Hi all,

    We have a user that is looking to have an altered delivery of his SmartNote to include checkboxes and other items that he can use when he prints out records, in addition to being able to print out one record per page (the important piece). I've been able to create a new master template with some Javascript to accomplish most of it, but have hit a problem when trying to recursively run through the records returned.

    Using the Template Tokens, I can get the number of rows returned with [rowcount?table=1]

    I then try using a 'for' loop to go through these records to display either the headers of the tables or the data itself.

    Using [cell?table=1&row=1&col=1] will give me the first header item. BUT, if I tried something like:


    for (x=0; x <= 13; x++) {
    [cell?table=1&row=1&col=x]
    }

    ... will not return a value. I guess I don't mind too much if I have to hard code the table headers, but looping recursively through the data elements is going to be a pain if the 'cell' Template Token does not allow you to pass it a variable.

    Has anyone tried anything like this and had any luck? You could bring back a little bit of my sanity :blink:
    Matthew Nye
    Veteran Member
    Posts: 514
    Veteran Member
      Randall,

      Congrats on using SmartNotes templates as they should be used. unfortunately the token templates are rendered on the server side, so by the time the javascript is run, they have already been converted to HTML. That means youre only option is to parse the HTML DOM itself looking for all your header names. You can identify the headers and the actual rows by using the css class definitions as such:

      notificationSectionLeft = header
      listCellEven or listCellOdd = data row

      I typically use jQuery to iterate, modify and add my HTML objects back to the DOM.

      It can be a bit daunting at first but once youve done it youd be surprised at all the cool things you can do with SmartNotes.
      If any of my answers were helpful an endorsement on LinkedIn would be much appriciated! www.linkedin.com/pub/matthew-nye/1a/886/760/
      Randall
      Veteran Member
      Posts: 44
      Veteran Member
        Awesome, thanks Matthew. I was toying around with jQuery a bit to parse the DOM, but wanted to make sure the 'cell' token wouldn't accept a variable. That definitely helps and I appreciate the response. Now let's see how far this rabbit hole goes :)

        Thanks!