Skip to content

Commit 6800057

Browse files
author
Kenneth Cheng
committed
column cell click function
1 parent aa8bc4b commit 6800057

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/VueExcelColumn.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ export default {
1616
textAlign: {type: String, default: null},
1717
keyField: {type: Boolean, default: false},
1818
sticky: {type: Boolean, default: false},
19+
listByClick: {type: Boolean, default: null},
1920
2021
validate: {type: Function, default: null},
2122
change: {type: Function, default: null},
2223
link: {type: Function, default: null},
24+
cellClick: {type: Function, default: null},
2325
autoFillWidth: {type: Boolean, default: false},
2426
2527
allowKeys: {type: [Array, Function], default () {return null}},
@@ -30,7 +32,7 @@ export default {
3032
options: {type: [Array, Object, Function], default () {return null}},
3133
summary: {type: String, default: null},
3234
sort: {type: Function, default: null},
33-
masking: {type: String, default: '*'},
35+
masking: {type: String, default: ''},
3436
placeholder: {type: String, default: ''},
3537
3638
toValue: {
@@ -205,6 +207,7 @@ export default {
205207
case 'password':
206208
break
207209
case 'action':
210+
this._listByClick = true
208211
break
209212
default:
210213
throw new Error('VueExcelColumn: Not supported type:' + this.type)
@@ -259,7 +262,9 @@ export default {
259262
toValue: this.toValue,
260263
toText: this.toText,
261264
register: this.register,
262-
placeholder: this.placeholder
265+
placeholder: this.placeholder,
266+
cellClick: this.cellClick,
267+
listByClick: this.listByClick || this._listByClick
263268
})
264269
}
265270
}

src/VueExcelEditor.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,10 +2244,14 @@ export default defineComponent({
22442244
const row = e.target.parentNode
22452245
const colPos = Array.from(row.children).indexOf(e.target) - 1
22462246
const rowPos = Array.from(row.parentNode.children).indexOf(row)
2247+
this.currentField = this.fields[colPos]
22472248
this.$emit('cell-click', {rowPos, colPos})
2249+
if (typeof this.currentField.cellClick === 'function')
2250+
this.currentField.cellClick(this.currentCell.textContent, this.currentRecord, rowPos, colPos, this.currentField, this)
22482251
this.moveInputSquare(rowPos, colPos)
22492252
if (this.currentField && this.currentField.link /* && e.altKey */)
22502253
setTimeout(() => this.currentField.link(this.currentCell.textContent, this.currentRecord, rowPos, colPos, this.currentField, this))
2254+
if (this.currentField.listByClick) return this.calAutocompleteList(true)
22512255
if (e.target.offsetWidth - e.offsetX > 15) return
22522256
if (this.currentField.readonly) return
22532257
this.inputBox.value = this.currentCell.textContent
@@ -2793,6 +2797,12 @@ input:focus, input:active:focus, input.active:focus {
27932797
font-size: 0.88rem;
27942798
max-width: 300px;
27952799
max-height: 235px;
2800+
animation: 0.3s ease 0s normal forwards 1 fadein;
2801+
}
2802+
@keyframes fadein {
2803+
0% { opacity: 0; }
2804+
66% { opacity: 0; }
2805+
100% { opacity: 1; }
27962806
}
27972807
.autocomplete-result {
27982808
list-style: none;

0 commit comments

Comments
 (0)