diff --git a/lib/ui/grid/column.js b/lib/ui/grid/column.js index 132929c..db5fd3d 100644 --- a/lib/ui/grid/column.js +++ b/lib/ui/grid/column.js @@ -312,7 +312,9 @@ export class GridDateColumn extends GridColumn { static setValue(element, val) { if (element.tagName === 'INPUT') { - if (isNaN(val)) { + if (val === '') { + element.value = ''; + } else if (isNaN(val)) { if (/^\d{4}-\d{2}-\d{2}$/.test(val)) { element.value = val; } else if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(val)) { diff --git a/lib/ui/grid/grid.d.ts b/lib/ui/grid/grid.d.ts index c944390..3522076 100644 --- a/lib/ui/grid/grid.d.ts +++ b/lib/ui/grid/grid.d.ts @@ -275,10 +275,10 @@ export class Grid { removeItem(index: number): GridItem; /** * 批量删除行数据 - * @param indexes 待删除的行索引数组 + * @param indexes 待删除的行索引数组,未传值时删除所有行 * @returns 返回已删除的行数据数组 */ - removeItems(indexes: Array): Array; + removeItems(indexes?: Array): Array; /** * 滚动到指定行的位置 * @param index 待滚动至的行索引 diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index cdc4ebf..e94587d 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -208,7 +208,8 @@ export class Grid { throw new Error('no source'); } if (!Array.isArray(array) || array.length <= 0) { - throw new Error(`invalid items array: ${array}`); + // throw new Error(`invalid items array: ${array}`); + return; } const it = index >= 0 ? this._var.currentSource[index] : null; if (it != null) { @@ -260,10 +261,11 @@ export class Grid { if (this._var.currentSource == null) { throw new Error('no source'); } - if (!Array.isArray(indexes) || indexes.length <= 0) { - throw new Error(`invalid selected indexes: ${indexes}`); + if (Array.isArray(indexes) && indexes.length > 0) { + indexes = indexes.slice().sort(); + } else { + indexes = this._var.currentSource.map(a => a.__index); } - indexes = indexes.slice().sort(); const array = []; let first = 0; for (let i = indexes.length - 1; i >= 0; --i) {