Fixed #495 - Add indentation property to TreeTable

pull/548/head
Cagatay Civici 2020-10-10 15:29:01 +03:00
parent ea3c291cac
commit cbbc56fabe
4 changed files with 18 additions and 3 deletions

View File

@ -34,6 +34,7 @@ export declare class TreeTable extends Vue {
filterLocale?: string; filterLocale?: string;
resizableColumns?: boolean; resizableColumns?: boolean;
columnResizeMode?: string; columnResizeMode?: string;
indentation?: number;
$emit(eventName: 'page', event: Event): this; $emit(eventName: 'page', event: Event): this;
$emit(eventName: 'sort', event: Event): this; $emit(eventName: 'sort', event: Event): this;
$emit(eventName: 'filter', event: Event): this; $emit(eventName: 'filter', event: Event): this;

View File

@ -47,7 +47,7 @@
<tbody class="p-treetable-tbody"> <tbody class="p-treetable-tbody">
<template v-if="!empty"> <template v-if="!empty">
<TTRow v-for="node of dataToRender" :key="node.key" :columns="columns" :node="node" :level="0" <TTRow v-for="node of dataToRender" :key="node.key" :columns="columns" :node="node" :level="0"
:expandedKeys="d_expandedKeys" @node-toggle="onNodeToggle" :expandedKeys="d_expandedKeys" @node-toggle="onNodeToggle" :indentation="indentation"
:selectionMode="selectionMode" :selectionKeys="selectionKeys" @node-click="onNodeClick" @checkbox-change="onCheckboxChange"></TTRow> :selectionMode="selectionMode" :selectionKeys="selectionKeys" @node-click="onNodeClick" @checkbox-change="onCheckboxChange"></TTRow>
</template> </template>
<tr v-else class="p-treetable-emptymessage"> <tr v-else class="p-treetable-emptymessage">
@ -206,6 +206,10 @@ export default {
columnResizeMode: { columnResizeMode: {
type: String, type: String,
default: 'fit' default: 'fit'
},
indentation: {
type: Number,
default: 1
} }
}, },
documentColumnResizeListener: null, documentColumnResizeListener: null,

View File

@ -18,7 +18,7 @@
</tr> </tr>
<template v-if="expanded && node.children && node.children.length"> <template v-if="expanded && node.children && node.children.length">
<sub-ttnode v-for="childNode of node.children" :key="childNode.key" :columns="columns" :node="childNode" :parentNode="node" :level="level + 1" <sub-ttnode v-for="childNode of node.children" :key="childNode.key" :columns="columns" :node="childNode" :parentNode="node" :level="level + 1"
:expandedKeys="expandedKeys" :selectionMode="selectionMode" :selectionKeys="selectionKeys" :expandedKeys="expandedKeys" :selectionMode="selectionMode" :selectionKeys="selectionKeys" :indentation="indentation"
@node-toggle="$emit('node-toggle', $event)" @node-click="$emit('node-click', $event)" @checkbox-change="onCheckboxChange"></sub-ttnode> @node-toggle="$emit('node-toggle', $event)" @node-click="$emit('node-click', $event)" @checkbox-change="onCheckboxChange"></sub-ttnode>
</template> </template>
</template> </template>
@ -59,6 +59,10 @@ export default {
level: { level: {
type: Number, type: Number,
default: 0 default: 0
},
indentation: {
type: Number,
default: 1
} }
}, },
data() { data() {
@ -261,7 +265,7 @@ export default {
}, },
togglerStyle() { togglerStyle() {
return { return {
marginLeft: this.level * 16 + 'px', marginLeft: this.level * this.indentation + 'rem',
visibility: this.leaf ? 'hidden' : 'visible' visibility: this.leaf ? 'hidden' : 'visible'
}; };
}, },

View File

@ -1485,6 +1485,12 @@ export default {
<td>string</td> <td>string</td>
<td>fit</td> <td>fit</td>
<td>Defines whether the overall table width should change on column resize, <br/> valid values are "fit" and "expand".</td> <td>Defines whether the overall table width should change on column resize, <br/> valid values are "fit" and "expand".</td>
</tr>
<tr>
<td>indentation</td>
<td>number</td>
<td>1</td>
<td>Indentation factor as rem value for children nodes. Defaults to 1rem.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>