The SAS Output Delivery System and reporting techniques

proc template tagset - call parent event

Reply
Regular Contributor
Posts: 187

proc template tagset - call parent event

Hi,

I created a new tagset called "ivb" with parent=tagsets.html4.
This tagset adds some javascript in the doc_head event.

Now I want to "subclass" the ivb tagset to add some extra javascript.
In the subclass I notice that the parent's doc_head event is overriden by the child's.
Is there a way to call the parent's doc_head event from the child?

-Bart
SAS Super FREQ
Posts: 8,861

Re: proc template tagset - call parent event

Posted in reply to bheinsius
Hi:
I'm not exactly sure what you mean by "subclass" but if your new template inherits from the parent of "ivb", then it will have the changed (or child) DOC_HEAD event. If your new template inherits from a parent of tagsets.html4, then you will have the original DOC_HEAD event.

A template can only have 1 parent. So when you use PARENT=IVB, if IVB has PARENT=TAGSETS.HTML4, all inheritance between IVB and HTML4 is resolved before IVB becomes the new parent.

One thing you might consider is having the DOC_HEAD event in each template trigger a new event, which will only write the JAVASCRIPT you want...something like this:
[pre]
define tagset ivb;
parent=tagsets.html4;
define event doc_head;
..... whatever you want here or just copy original ....
...... but add your own "trigger" statement ....
trigger ivb_js;
end;
define event ivb_js;
....your "ivb" javascript stuff is here...
end;
[/pre]

and then your new "subclass" tagset template:
[pre]
define tagset subclass;
parent=tagsets.ivb;

define event ivb_js;
** what is here overrides what is in tagsets.ivb;
trigger sub_js;
end;
define event sub_js;
... put your subclass javascript here ...
end;
[/pre]

Or, alternately, just have the "subclass" tagset template inherit from tagsets.html4 instead of from tagsets.ivb:
[pre]
define tagset subclass;
parent=tagsets.html4;
define event doc_head;
..... whatever you want here or just copy original ....
...... but add your own "trigger" statement ....
trigger sub_js;
end;
define event sub_js;
....your "subclass" javascript stuff is here...
end;
[/pre]


I haven't tested it out, since I don't know enough JavaScript to be useful, but an approach like this might do what you want, depending on what you mean by "subclass".

cynthia
SAS Employee
Posts: 95

Re: proc template tagset - call parent event

Posted in reply to bheinsius
I understand your pain completely. Unfortunately the tagset language does not have the ability to sub class or call a parent's event. I have wanted this ability for a long time, but have never managed to get around to it. Inheritance is rather simplistic, but very straight forward.

The method that Cynthia outlined is the easiest way. Create a new event in the parent, or in your's that does the functionality you need so it won't be over written by the child tagset.

The initialize event in the html and Excel tagsets does this sort of thing. Since initialize is an ODS event, over riding it and keeping some or all of the parent's functionality can be a pain. So all it does is trigger other events that do the actual work. It's a whole lot easier to copy that, and use the sub-events than if it were to have a bunch of tagset code in it.
Regular Contributor
Posts: 187

Re: proc template tagset - call parent event

Hi Cynthia@SAS and Eric@SAS,

Thanks for your suggestions.
Sounds like a solution that will work!

Thanks,
-Bart
Ask a Question
Discussion stats
  • 3 replies
  • 264 views
  • 0 likes
  • 3 in conversation