ForgeComponents
en

Components

j-Children

jComponent 20 · jcomponent@20 component Example loaded with jComponent 20

The component renders draggable items as a tree without the possibility of collapsing. Data-Source must be Object Array in the form: { id: String, children: [ ], YOUR PROPERTIES }, { ... }


Configuration:

  • empty {String} an empty text (default: null)
  • onchange {String} optional, a link to the function(arr) - captures items when resorted

Template:

{{ level }} contains a level (number)
{{ value }} contains an item (object)

Try to understand the functionality from the example.

Good to know:

  • component.items {Object} contains all references of all items in the form items[item.id] = item
  • component.parents {Object} contains all references of all parents in the form parents[item.id] = parent

Use it with <ui-component name="children">. When the component is not loaded yet, jComponent downloads it on first use from the address in DEF.fallback (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

example.html
<ui-component name="children" path="mynav">
	<script type="text/html">
		<div style="background:#F0F0F0;padding:8px;border-radius:var(--radius);margin-bottom:2px;margin-left:{{ level * 30 }}px">{{ value.name }}</div>
	</script>
</ui-component>

<script>
	var mynav = [{ id: '1', name: 'Level 1', children: [{ id: '1-1', name: 'Level 1-1' }, { id: '1-2', name: 'Level 1-2', children: [{ id: '1-2-1', name: 'Level 1-2-1' }, { id: '1-2-2', name: 'Level 1-2-2' }, { id: '1-2-3', name: 'Level 1-2-3' }] }] }, { id: '2', name: 'Level 2' }];
</script>