leave edit event
This commit is contained in:
@ -359,6 +359,24 @@ export class Grid {
|
||||
}
|
||||
|
||||
reload(keep) {
|
||||
const filtered = this.columns.some(c => c.filterValues != null);
|
||||
if ((filtered ^ this._var.colAttrs.__filtered) === 1) {
|
||||
this._var.colAttrs.__filtered = filtered;
|
||||
const headers = this._var.refs.header.children;
|
||||
for (let i = 0; i < this.columns.length; ++i) {
|
||||
const ele = headers[i].querySelector('.filter');
|
||||
if (ele == null) {
|
||||
continue;
|
||||
}
|
||||
if (this.columns[i].filterValues != null) {
|
||||
ele.classList.add('active');
|
||||
} else {
|
||||
ele.classList.remove('active');
|
||||
}
|
||||
}
|
||||
this._refreshSource();
|
||||
return;
|
||||
}
|
||||
let length = this._var.currentSource.length;
|
||||
if (this.extraRows > 0) {
|
||||
length += this.extraRows;
|
||||
@ -699,12 +717,6 @@ export class Grid {
|
||||
row.classList.remove('selected');
|
||||
}
|
||||
// data
|
||||
// const selectChanged = vals.__selected ^ selected;
|
||||
// if (selected) {
|
||||
// vals.__selected = true;
|
||||
// } else {
|
||||
// delete vals.__selected;
|
||||
// }
|
||||
cols.forEach((col, j) => {
|
||||
if (col.visible === false) {
|
||||
return;
|
||||
@ -734,9 +746,14 @@ export class Grid {
|
||||
const type = isCheckbox ? GridCheckboxColumn : this._var.colTypes[col.key] ?? GridColumn;
|
||||
let element;
|
||||
if (!isCheckbox && typeof type.createEdit === 'function') {
|
||||
if (vals.__editing?.[col.key] && type.editing) {
|
||||
val = type.getValue({ target: cell.children[0] }, col);
|
||||
this._onRowChanged(null, startIndex + i, col, val, cell, true);
|
||||
if (vals.__editing?.[col.key]) {
|
||||
if (typeof type.leaveEdit === 'function') {
|
||||
type.leaveEdit(cell.children[0], this._var.el);
|
||||
}
|
||||
if (type.editing) {
|
||||
val = type.getValue({ target: cell.children[0] }, col);
|
||||
this._onRowChanged(null, startIndex + i, col, val, cell, true);
|
||||
}
|
||||
}
|
||||
element = selected ?
|
||||
type.createEdit(e => this._onRowChanged(e, startIndex + i, col, type.getValue(e, col), cell), col, this._var.el, vals) :
|
||||
@ -1184,7 +1201,7 @@ export class Grid {
|
||||
reset.innerText = this.langs.reset;
|
||||
reset.addEventListener('click', () => {
|
||||
delete col.filterValues;
|
||||
this._var.colAttrs.__filtered = this.columns.some(c => col.filterValues != null)
|
||||
this._var.colAttrs.__filtered = this.columns.some(c => c.filterValues != null)
|
||||
this._refreshSource();
|
||||
if (typeof col.onFiltered === 'function') {
|
||||
col.onFiltered.call(this, col);
|
||||
|
Reference in New Issue
Block a user