PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 04/15/2013 12:55 PM by  Randall
Javascript in SmartNote Template
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
Randall
Private
Private
(99 points)
Posts:41


Send Message:

--
04/15/2013 12:27 PM
    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
    Private
    Private
    Veteran Member
    (1532 points)
    Veteran Member
    Posts:514


    Send Message:

    --
    04/15/2013 12:43 PM
    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
    Private
    Private
    (99 points)
    Posts:41


    Send Message:

    --
    04/15/2013 12:55 PM
    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!
    You are not authorized to post a reply.