fix some issues

This commit is contained in:
Chen Lily 2024-01-29 12:44:03 +08:00
parent 56262d6766
commit 0696ecaff0
3 changed files with 11 additions and 7 deletions

View File

@ -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)) {

View File

@ -275,10 +275,10 @@ export class Grid {
removeItem(index: number): GridItem;
/**
*
* @param indexes
* @param indexes
* @returns
*/
removeItems(indexes: Array<number>): Array<GridItem>;
removeItems(indexes?: Array<number>): Array<GridItem>;
/**
*
* @param index

View File

@ -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) {