# j-Children

> 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 }, { ... }

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: f95274001185d41d2fe27982f66f2b59631854af969288b56960e98d13429e1b
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

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__:

```html
{{ 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.

```html 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>
```
