Skip to content

Commit 5135908

Browse files
authored
Merge pull request #265 from balajidharma/fix/nested-sort-issue
fix for sort issue with nested values
2 parents ab22975 + 49e64fe commit 5135908

File tree

4 files changed

+45
-40
lines changed

4 files changed

+45
-40
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"author": "HC200ok",
44
"description": "A customizable and easy-to-use data table component made with Vue.js 3.x.",
55
"private": false,
6-
"version": "1.5.42",
6+
"version": "1.5.43",
77
"types": "./types/main.d.ts",
88
"license": "MIT",
99
"files": [
@@ -59,5 +59,3 @@
5959
"vue-tsc": "^0.34.7"
6060
}
6161
}
62-
63-

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
2-
<ServerSideMode />
2+
<!-- <ServerSideMode /> -->
33
<br><br>
4-
<!-- <ClientMode /> -->
4+
<ClientMode />
55
<br><br>
66
<!-- <ExpandLoading/> -->
77
</template>

src/modes/Client.vue

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@
3838
multi-sort
3939
body-text-direction="left"
4040
header-text-direction="left"
41-
:filter-options="filterOptions"
4241
click-event-type="double"
4342
@select-row="showItem"
4443
@deselect-row="deselectRow"
4544
@update-page-items="updateItems"
4645
@update-total-items="updateTotalItems"
4746
show-index-symbol="$"
4847
>
49-
<template #customize-headers>
48+
<!-- <template #customize-headers>
5049
<thead class="my-static-header">
5150
<tr>
5251
<th colspan="3" rowspan="2"></th>
@@ -64,7 +63,7 @@
6463
<th>country</th>
6564
</tr>
6665
</thead>
67-
</template>
66+
</template> -->
6867
<template #expand="item">
6968
<div style="padding: 15px">
7069
{{ item.name }} won championships
@@ -166,25 +165,25 @@ const updateTotalItems = (items: Item[]) => {
166165
console.log(JSON.stringify(items));
167166
};
168167
169-
// const items = ref<Item[]>([
170-
// { name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
171-
// { name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
172-
// { name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
173-
// { name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
174-
// { name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
175-
// { name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
176-
// { name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
177-
// { name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
178-
// { name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
179-
// { name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
180-
// { name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
181-
// { name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
182-
// { name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
183-
// { name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
184-
// { name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
185-
// ]);
186-
187-
const items = ref<Item[]>(mockClientItems());
168+
const items = ref<Item[]>([
169+
{ name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
170+
{ name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
171+
{ name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
172+
{ name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
173+
{ name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
174+
{ name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
175+
{ name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
176+
{ name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
177+
{ name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
178+
{ name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
179+
{ name: "Stephen Curry", firstName: "GSW", number: 30, position: 'G', indicator: {"height": '6-2', "weight": 185}, lastAttended: "Davidson", country: "USA"},
180+
{ name: "Kevin Durant", firstName: "BKN", number: 7, position: 'F', indicator: {"height": '6-10', "weight": 240}, lastAttended: "Texas-Austin", country: "USA"},
181+
{ name: "Lebron James", firstName: "LAL", number: 7, position: 'F', indicator: {"height": '6-9', "weight": 185}, lastAttended: "St. Vincent-St. Mary HS (OH)", country: "USA"},
182+
{ name: "Giannis Antetokounmpo", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 242}, lastAttended: "Filathlitikos", country: "Greece"},
183+
{ name: "HC", firstName: "MIL", number: 34, position: 'F', indicator: {"height": '6-11', "weight": 243}, lastAttended: "Filathlitikos", country: "Greece"},
184+
]);
185+
186+
// const items = ref<Item[]>(mockClientItems());
188187
189188
// const headers: Header[] = [
190189
// { text: 'Name', value: 'name'},
@@ -220,15 +219,15 @@ const favouriteSportCriteria = ref('all');
220219
const showNameFilter = ref(false);
221220
const nameCriteria = ref('');
222221
223-
const filterOptions = computed((): FilterOption[] => {
224-
const filterOptionsArray: FilterOption[] = [];
225-
filterOptionsArray.push({
226-
field: 'name',
227-
criteria: ['name-1', 'name-2'],
228-
comparison: 'in',
229-
});
230-
return filterOptionsArray;
231-
});
222+
// const filterOptions = computed((): FilterOption[] => {
223+
// const filterOptionsArray: FilterOption[] = [];
224+
// filterOptionsArray.push({
225+
// field: 'name',
226+
// criteria: ['name-1', 'name-2'],
227+
// comparison: 'in',
228+
// });
229+
// return filterOptionsArray;
230+
// });
232231
233232
const bodyRowClassNameFunction: BodyRowClassNameFunction = (item: Item, index: number): string => (index === 0 ? 'first-row test-row' : '');
234233
const bodyExpandRowClassNameFunction: BodyRowClassNameFunction = (item: Item, index: number): string => 'expand-row';

src/utils.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@ import type { Item } from './types/main';
22

33
export function getItemValue(column: string, item: Item) {
44
if (column.includes('.')) {
5-
let content: any = '';
65
const keys = column.split('.');
76
const { length } = keys;
7+
8+
let content;
89
let i = 0;
10+
911
while (i < length) {
10-
content = (i === 0 ? item[keys[i]] : content[keys[i]]);
12+
if (i === 0) {
13+
content = item[keys[0]];
14+
} else if (content && typeof content === 'object') {
15+
content = content[keys[i]];
16+
} else {
17+
content = '';
18+
break;
19+
}
1120
i += 1;
12-
if (content === undefined) break;
1321
}
14-
return content;
22+
return content ?? '';
1523
}
1624
return item[column] ?? '';
1725
}

0 commit comments

Comments
 (0)