Home Forums General XMetaL Discussion Structure view: how to set the initial collapse level? Reply To: Structure view: how to set the initial collapse level?

Derek Read

Reply to: Structure view: how to set the initial collapse level?

I'm still not exactly sure what you want, but I will take a guess that adding another loop will be enough. In this example the nodes in the Structure View at a specific level as well as nodes within that level will be collapsed. The user will then need to expand multiple levels to see the inner content. That seems annoying to me, so I'm not sure that is what you really want.

If that sounds right please try the following.

[code=structureViewDefaultCollapse.mcr]

var level = 3; //hopefully you don't need to change anything from here on down
ActiveDocument.FormattingUpdating = false;
var origSelection = ActiveDocument.Range; for(var j=0;j var ancestors = j;
var xpath = “//*[count(ancestor::*) = ” + ancestors + “]”;
var nodes = ActiveDocument.documentElement.getNodesByXPath(xpath);
for(var i=0;i Selection.SelectNodeContents(nodes.item(i));
Selection.SVCollapsedContainer = true;
} } origSelection.Select();
ActiveDocument.FormattingUpdating = true;
]]>

[/code]

Reply

Products
Downloads
Support