# j-Table

> Wyświetlanie rekordów w ustawionym tabeli.

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

- `j-Table` Jest to bardzo prosta alternatywa dla `j-DataGrid` Celem jest UI
- `data-source` oczekuje `Array` lub `Object` z `{ page: 1, pages: 10, limit: 50, items: [], count: 1000 }`

__Konfiguracja__:

- `highlight {Boolean}` umożliwia podkreślenie kolejności (default: `true`)
- `unhighlight {Boolean}` umożliwia podwyższanie kolejności (default: `true`)
- `multiple {Boolean}` umożliwia wielokrotne podkreślenie (default: `false`)
- `detail {Boolean/String}` jeśli wartość `string` to wartość musi być linkem do `function(row_data, next_fn(new_data_for_detail_template_OR__new_html), tdelement)`
- `exec {String}` Droga do `function(row/rows)` lub drogi do `variable`
- `remember {Boolean}` umożliwia zapamiętanie ostatnich wybranych kolejek (default: `false`)
- `pk {String}` klucz podstawowy (default: `id`)
- `border {Boolean}` umożliwia granicę (default: `true`)
- `scrollbar {Boolean}` Umożliwia przystosowane skręcanie (default): `false`+ Ważne jest: `height` Należy określić
- `height {Number/String}` Wysokość sieci lub może zawierać selektor `window`, `parent` lub Custom Selector `.ui-viewbox-body`
- `paginate {String}` link do `function(model)` do wykonania strony `{ page: 1, limit: 10, sort: [] }`
- `redraw {String}` jest linkem do funkcji, ocenia się, gdy tabela jest odtwarzana
- `filter {String}` to link do funkcji, który jest oceniany przed tabelą
- `dblclick {String}` to link do funkcji, który jest oceniany, gdy użytkownik wykonuje podwójne kliknięcie
- `datasource {String}` ścieżka do źródła danych (dla innych dodatkowych danych w szablonie. `{{ $.data.something }}`)
- `click {String}` jest drogą do `function(button_name, row, button_element)`, gdy użytkownik kliknie przycisk
- `flat {Boolean}` usuwa podkładki w komórkach (default: `false`)
- `noborder {Boolean}` usuwa granicę wokół (default: `false`)
- __NEW__: `hidewhenempty {Boolean}` ukrywa tabelę, gdy jest pusta (default: `false`)

__Dobrze wiedzieć__:

- Każdy element `tr` zawiera atrybut `data-index` z indeksem `row`.
- Każdy element `td` zawiera atrybut `data-index` z indeksem `row`.

__Definicja HTML__:

```html
<ui-component name="table" path="" config="">

	<!--
		data-size="TD1,TD2,TD3"      : column width, optional (can contain pixels or percentage), "0" means "auto" width
		data-head="TD1,TD2,TD3"      : column names, optional
		data-align="TD1,TD2,TD3"     : column align, optional (0: left, 1: center, 2: right)
		data-type="TYPE"             : can be "detail" (Tangular template) or "empty" (empty is rendered when the Array is empty)
		data-display="MD,XS"         : can contain display types "LG" large, "MD" medium, "SM" small, "XS" extra small
		data-sort="name,,price"      : enables sorting, can contain the name of fields (a column with empty value will have disabled sorting)
	-->
	<script type="text/html" data-size="0,150px,50px" data-head="Name,Created,Opt" data-align="0,0,1" data-sort="1">
		<tr>
			<td>{{ name }}</td>
			<td>{{ dtcreated | format('[date]') }}</td>
			<td>OK</td>
		</tr>
	</script>

	<script type="text/html" data-type="detail">
		DETAIL: {{ name }}
		HIDDEN COMMANDS: {{ $.index }} or {{ $.user }}
	</script>

	<script type="text/html" data-type="empty">
		EMPTY
	</script>

</ui-component>
```

__Dobrze wiedzieć__:

- `data-head` może zawierać ikonę Font Awesome, musi być włożony jak ten `data-head="Name,'cog'"` lub `data-name="Name,'youtube fab'"`
- `NULL('link.to.data')` oceny `config.paginate`

Użyj go z `<ui-component name="table">`Gdy element nie jest jeszcze ładowany, jComponent Pobierz go po pierwszym użyciu z adresu `DEF.fallback` (Wydaje się Componentator Autor: Peter Širka Źródło: Componentator Zestaw składników, licencja MIT.

```html example.html
<style>
	body{padding:50px;margin:0;font-family:Arial;height:100%;}
	html{height:100%;}
</style>

<ui-component name="table" path="items" config="detail:true;datasource:extra">

	<!-- WITHOUT HEADERS -->

	<script type="text/html" data-size="0,120px,120px" data-head="Name,Price,Controls" data-align="0,2,1" data-sort="name,price,">
		<tr>
			<td><b>{{ $.data.author }}:</b> {{ name }}</td>
			<td class="right">{{ price | format(2) }} &euro;</td>
			<td class="center"><button><i class="ti ti-search"></i></button><button><i class="ti ti-pencil"></i></button><button class="red" disabled><i class="ti ti-trash"></i></button></td>
		</tr>
	</script>

	<script type="text/html" data-type="detail">
		<div class="padding npt npb">
			<div>Author: <b>{{ $.data.author }}</b></div>
			<div>Role: <b>{{ $.data.role }}</b></div>
			<div>Name: <b>{{ name }}</b></div>
			<div>Description: <b>{{ description }}</b></div>
		</div>
	</script>

	<script type="text/html" data-type="empty">
		No data
	</script>

</ui-component>

<br />

<ui-component name="table" path="items" config="border:0">

	<!-- WITHOUT HEADERS -->
	<script type="text/html" data-size="0,120px,120px">
		<tr>
			<td>{{ name }}</td>
			<td class="right">{{ price | format(2) }} &euro;</td>
			<td class="center">{{ created | format('yyyy-MM-dd') }}</td>
		</tr>
	</script>

	<script type="text/html" data-type="empty">
		No data
	</script>

</ui-component>

<script>

	var items = [];
	var extra = {
		author: 'Brutus',
		role: 'Planter'
	};

	items.push({ name: '1 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 233, created: new Date().add('-5 days') });
	items.push({ name: '2 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 122, created: new Date().add('-1 year') });
	items.push({ name: '3 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 119, created: new Date().add('-1 month') });
	items.push({ name: '4 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 35.34, created: new Date().add('-14 days') });
	items.push({ name: '5 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 439.33, created: new Date().add('-5 hours') });
	items.push({ name: '6 Lorem ipsum dolor.', description: 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consectetur, mollitia!', price: 111.12, created: new Date().add('-349 minutes') });

</script>
```
