renderjson icon indicating copy to clipboard operation
renderjson copied to clipboard

Feature Request

Open DonGar opened this issue 8 years ago • 3 comments

This is an amazing tool, thank you for building it!

I'd like to be able to update the json structure dynamically and preserve which nodes are open or folded.

Perhaps by having a way to query for the currently 'open' nodes, and to pass that result in when generating the replacement HTML. The query result would have to be somewhat aware of the data content so that nodes not present after the update are ignored. This same mechanism could be used to give people fine grained control over which nodes are opened during the initial display.

DonGar avatar Apr 03 '17 07:04 DonGar

+1, would be wonderful to programmatically control what's expanded and what isn't

razor-1 avatar Aug 07 '17 22:08 razor-1

Yes, I was really looking for a ElementWrapper.expandAll() function.

adjenks avatar Oct 30 '18 21:10 adjenks

Here's a wacky method to open the next layer of all of the trees on the page:

document.querySelectorAll('span:not([class]').forEach(function (el) {
	var a = (((el.children[0] || {}).children|| [])[0] || {});
	(a.click || function(){} ).bind(a)();
})

In english: Get the first child of the first child of the span elements without class attributes, and click them all.

Be careful though, If this matches some similar structure on your page, you might click something you don't want to click.

adjenks avatar Oct 30 '18 22:10 adjenks