Fixed #939 - Optional chaining not working for TreeTable in version 3.2.1

pull/973/head
Cagatay Civici 2021-02-04 16:09:00 +03:00
parent 552288556f
commit 5c0e0bf95d
2 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@
<th v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :style="columnProp(col, 'headerStyle')" :class="getColumnHeaderClass(col)" @click="onColumnHeaderClick($event, col)" <th v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :style="columnProp(col, 'headerStyle')" :class="getColumnHeaderClass(col)" @click="onColumnHeaderClick($event, col)"
:tabindex="columnProp(col, 'sortable') ? '0' : null" :aria-sort="getAriaSort(col)" @keydown="onColumnKeyDown($event, col)"> :tabindex="columnProp(col, 'sortable') ? '0' : null" :aria-sort="getAriaSort(col)" @keydown="onColumnKeyDown($event, col)">
<span class="p-column-resizer" @mousedown="onColumnResizeStart" v-if="resizableColumns"></span> <span class="p-column-resizer" @mousedown="onColumnResizeStart" v-if="resizableColumns"></span>
<component :is="col.children?.header" :column="col" /> <component :is="col.children.header" :column="col" v-if="col.children && col.children.header" />
<span class="p-column-title" v-if="columnProp(col, 'header')">{{columnProp(col, 'header')}}</span> <span class="p-column-title" v-if="columnProp(col, 'header')">{{columnProp(col, 'header')}}</span>
<span v-if="columnProp(col, 'sortable')" :class="getSortableColumnIcon(col)"></span> <span v-if="columnProp(col, 'sortable')" :class="getSortableColumnIcon(col)"></span>
<span v-if="isMultiSorted(col)" class="p-sortable-column-badge">{{getMultiSortMetaIndex(col) + 1}}</span> <span v-if="isMultiSorted(col)" class="p-sortable-column-badge">{{getMultiSortMetaIndex(col) + 1}}</span>
@ -32,14 +32,14 @@
</tr> </tr>
<tr v-if="hasColumnFilter()"> <tr v-if="hasColumnFilter()">
<th v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :class="getFilterColumnHeaderClass(col)" :style="columnProp(col, 'filterHeaderStyle')"> <th v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :class="getFilterColumnHeaderClass(col)" :style="columnProp(col, 'filterHeaderStyle')">
<component :is="col.children?.filter" :column="col" v-if="col.children?.filter"/> <component :is="col.children.filter" :column="col" v-if="col.children && col.children.filter"/>
</th> </th>
</tr> </tr>
</thead> </thead>
<tfoot class="p-treetable-tfoot" v-if="hasFooter"> <tfoot class="p-treetable-tfoot" v-if="hasFooter">
<tr> <tr>
<td v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :style="columnProp(col, 'footerStyle')" :class="columnProp(col, 'footerClass')"> <td v-for="(col,i) of columns" :key="columnProp(col, 'columnKey')||columnProp(col, 'field')||i" :style="columnProp(col, 'footerStyle')" :class="columnProp(col, 'footerClass')">
<component :is="col.children?.footer" :column="col" /> <component :is="col.children.footer" :column="col" v-if="col.children && col.children.footer" />
{{columnProp(col, 'footer')}} {{columnProp(col, 'footer')}}
</td> </td>
</tr> </tr>
@ -773,7 +773,7 @@ export default {
hasColumnFilter() { hasColumnFilter() {
if (this.columns) { if (this.columns) {
for (let col of this.columns) { for (let col of this.columns) {
if (col.children?.filter) { if (col.children && col.children.filter) {
return true; return true;
} }
} }
@ -858,7 +858,7 @@ export default {
let hasFooter = false; let hasFooter = false;
for (let col of this.columns) { for (let col of this.columns) {
if (this.columnProp(col, 'footer')|| col.children?.footer) { if (this.columnProp(col, 'footer')|| (col.children && col.children.footer)) {
hasFooter = true; hasFooter = true;
break; break;
} }

View File

@ -12,7 +12,7 @@
<span :class="checkboxIcon"></span> <span :class="checkboxIcon"></span>
</div> </div>
</div> </div>
<component :is="col.children?.body" :node="node" :column="col" v-if="col.children?.body" /> <component :is="col.children.body" :node="node" :column="col" v-if="col.children && col.children.body" />
<template v-else><span>{{resolveFieldData(node.data, columnProp(col, 'field'))}}</span></template> <template v-else><span>{{resolveFieldData(node.data, columnProp(col, 'field'))}}</span></template>
</td> </td>
</tr> </tr>