Skip to content

Commit

Permalink
passed textAlign to KTableGridItem
Browse files Browse the repository at this point in the history
  • Loading branch information
BabyElias committed Sep 7, 2024
1 parent d41aef2 commit 7acfa97
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
6 changes: 3 additions & 3 deletions docs/pages/ktable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
caption="Non Sortable Table"
>

<template #header="{ header, index }">
<template #header="{ header, colIndex }">
<span>{ header.label } (Backend)</span>
</template>
<template #cell="{ content, rowIndex, colIndex }">
Expand Down Expand Up @@ -64,7 +64,7 @@
:rows="rows"
caption="Non-sortable table"
>
<template #header="{ header, index }">
<template #header="{ header, colIndex }">
<span>{{ header.label }} (Backend)</span>
</template>
<template #cell="{ content, rowIndex, colIndex }">
Expand All @@ -79,7 +79,7 @@
<p>
The <code>KTable</code> can be used with default sorting functionality, allowing you to sort data on the client side without the need for server requests. There are 4 permissible data types - <code>string</code>,<code>number</code>,<code>date</code> and <code>undefined</code>. Columns declared with <code>undefined</code> data type are not sortable. This example demonstrates a table with default sorting enabled.
</p>

<DocsShowCode language="html">
<KTable
:headers="headers"
Expand Down
20 changes: 4 additions & 16 deletions lib/KTable/KTableGridItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,13 @@

<script>
import { DATA_TYPE_NUMERIC } from './useSorting';
export default {
name: 'KTableGridItem',
props: {
content: {
type: [String, Number, Boolean, Object, Array],
required: true,
},
dataType: {
type: String,
default: 'string',
},
rowIndex: {
type: Number,
required: true,
Expand All @@ -47,6 +41,10 @@
type: String,
default: 'auto',
},
textAlign: {
type: String,
required: true,
},
},
computed: {
coreOutlineFocus() {
Expand All @@ -57,16 +55,6 @@
},
};
},
textAlign() {
const alignLtr = this.dataType === DATA_TYPE_NUMERIC ? 'right' : 'left';
if (this.isRtl && alignLtr === 'right') {
return 'left';
}
if (this.isRtl && alignLtr === 'left') {
return 'right';
}
return alignLtr;
},
},
methods: {
onKeydown(event) {
Expand Down
5 changes: 4 additions & 1 deletion lib/KTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
@click="sortable ? handleSort(index) : null"
@keydown="handleKeydown($event, -1, index)"
>
<slot name="header" :header="header" :colindex="index">
<!--@slot Scoped slot for customizing the content of each header cell. Provides a header object `header` and its column index `colIndex`.-->
<slot name="header" :header="header" :colIndex="index">
{{ header.label }}
</slot>
<span v-if="isColumnSortable(index)" class="sort-icon">
Expand Down Expand Up @@ -63,6 +64,7 @@
:width="headers[colIndex].width"
:rowIndex="rowIndex"
:colIndex="colIndex"
:textAlign="getTextAlign(headers[colIndex].dataType)"
:class="{
'sticky-column': colIndex === 0,
}"
Expand All @@ -73,6 +75,7 @@
@keydown="handleKeydown($event, rowIndex, colIndex)"
>
<template #default="slotProps">
<!--@slot Scoped slot for customizing the content of each data cell. Provides the content of a data cell `content`, its row index `rowIndex`, its column index `colIndex`, and the corresponding whole row object `row`.-->
<slot name="cell" :content="slotProps.content" :rowIndex="rowIndex" :colIndex="colIndex" :row="row">
{{ slotProps.content }}
</slot>
Expand Down

0 comments on commit 7acfa97

Please sign in to comment.