Jump to content

Calendar Revisited


sschardan

Recommended Posts

Dan Korn was of great assistance to me on a calendar project last year per this post

 

http://forums.pti.com/showthread.php?t=1608&highlight=calendar

 

We now have a client that wants to do a similar project with one tweak, they want the custom dates to be highlighted. I thought I had it with the following code addition:

 

        var key = [Month, theDate.getDate(), Field("Cal_ID")].join('\t');
       if (SortedEvents[key])

       result += "<cell shading=Hilight,100>" + SortedEvents[key].join("<br>\n");

 

However, this results in the custom text and cell shading to be in the cell to the right of the desired cell, thus filling in the wrong date.

 

So I tried this:

 

        var key = [Month, theDate.getDate(), Field("Cal_ID")].join('\t');
       if (SortedEvents[key])

       result += SortedEvents[key].join("<br>\n") + "<cell shading=Hilight,100>";

 

This results in the custom text being in the correct cell, but the shading is in the cell to the right, thus highlighting the wrong date.

 

When rendering, I get an error of "Extra cell started.... Ignoring". I am attaching sample pdf's to show the results. Is there a way to get this to work correctly?

 

Thank you.

 

FusionPro 7.2P1d

Mac OS 10.6

Acrobat 9

Test Hilights Rendered.pdf

Test Hilights Rendered 2.pdf

Link to comment
Share on other sites

I tried reviewing what Dan provided last time and cross-referencing that with the code snippets you provided, but without seeing your entire, current rule set, it's hard to figure out how the snippets above are being implemented into your entire table (i.e. what the value of "result" is at any given point).

 

With that said, it sounds as if the variable result has already generated your cell contents and you are attempting to add formatting tags to the end of the result. Instead, I wonder if you could insert your formatting before the result AND your SortedEvents data after by doing something like:

result = "<cell shading=Hilight,100>" + result + SortedEvents[key].join("<br>\n");

Again, without seeing how "result" is being built from the beginning, this is just a guess. ;)

Link to comment
Share on other sites

Thanks Eric, but that isn't working. I finally did come up with something that is working. The problem was that my cell shading tag was creating an additional cell. I had to remove my cell creation tag from higher up in my rule, then embed it inside the various if statements within the loop. Here is the loop portion of my rule:

 

do
{
 result += "\n<row>";
 for (var day = 0; day < 8; day++)
 {
   result += "\n\t";

   if (day == 0)

   {
       result += "<cell>";
       result += "<p br=false cellalignment=bottom>";
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       result += '<br>';
       theDate.setDate(theDate.getDate() - 1);
   }

   else

   if (theDate.getMonth() == JSMonth)
   {



       var key = [Month, theDate.getDate(), Field("Cal_ID")].join('\t');
       if (SortedEvents[key])

       result += "<cell shading=Hilight,100><p br=false cellalignment=bottom>" + SortedEvents[key].join("<br>\n");

       if (!SortedEvents[key])
       result += "<cell><p br=false cellalignment=bottom>"
   }

   theDate.setDate(theDate.getDate() + 1);
 }
}
while (theDate.getMonth() != (JSMonth+1)%12)

result += "\n</table>";
return result;

 

I'm sure there is a more elegant way to accomplish this, but this is the best that this hacker can come up with for now!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...