|
@ -21,7 +21,8 @@ export class RowData extends Base { |
|
|
this.checkLastRow = this.checkLastRow.bind(this); |
|
|
this.checkLastRow = this.checkLastRow.bind(this); |
|
|
this.setExtraProperty = this.setExtraProperty.bind(this); |
|
|
this.setExtraProperty = this.setExtraProperty.bind(this); |
|
|
this.arrayOrderBy = this.arrayOrderBy.bind(this); |
|
|
this.arrayOrderBy = this.arrayOrderBy.bind(this); |
|
|
this.getRowSelectable = this.getRowSelectable.bind(this); |
|
|
this.getSelectable = this.getSelectable.bind(this); |
|
|
|
|
|
this.getTreeTickable = this.getTreeTickable.bind(this); |
|
|
this.mergeSortFields = this.mergeSortFields.bind(this); |
|
|
this.mergeSortFields = this.mergeSortFields.bind(this); |
|
|
this.mergeDefaultSortBy = this.mergeDefaultSortBy.bind(this); |
|
|
this.mergeDefaultSortBy = this.mergeDefaultSortBy.bind(this); |
|
|
this.rowDataExtraPropertyHandle = this.rowDataExtraPropertyHandle.bind(this); |
|
|
this.rowDataExtraPropertyHandle = this.rowDataExtraPropertyHandle.bind(this); |
|
@ -366,7 +367,10 @@ export class RowData extends Base { |
|
|
rowData[this.props.tickedField] = this.getInitRowTicked(rowData); |
|
|
rowData[this.props.tickedField] = this.getInitRowTicked(rowData); |
|
|
rowData[this.props.selectedField] = this.getInitRowSelected(rowData); |
|
|
rowData[this.props.selectedField] = this.getInitRowSelected(rowData); |
|
|
rowData[Constant.FIELD_NAMES.ROW_OLD_VALUE] = {}; |
|
|
rowData[Constant.FIELD_NAMES.ROW_OLD_VALUE] = {}; |
|
|
rowData[Constant.FIELD_NAMES.SELECTABLE] = this.getSelectable(rowData); |
|
|
rowData[Constant.FIELD_NAMES.SELECTABLE] = this.getInitSelectable(rowData); |
|
|
|
|
|
if (this.props.tree) { |
|
|
|
|
|
rowData[Constant.FIELD_NAMES.TREE_TICKABLE] = this.getInitTreeTickable(rowData); |
|
|
|
|
|
} |
|
|
this.setOldValue(rowData); |
|
|
this.setOldValue(rowData); |
|
|
if (this.props.tree) { |
|
|
if (this.props.tree) { |
|
|
if (this.table.store.expandDatas.length > 0 && this.table.store.expandDatas.includes(rowData[this.props.primaryKey])) { |
|
|
if (this.table.store.expandDatas.length > 0 && this.table.store.expandDatas.includes(rowData[this.props.primaryKey])) { |
|
@ -381,11 +385,11 @@ export class RowData extends Base { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取是否可选 |
|
|
* 获取行数据初始化可选状态 |
|
|
* @param rowData |
|
|
* @param rowData |
|
|
* @returns |
|
|
* @returns |
|
|
*/ |
|
|
*/ |
|
|
private getSelectable(rowData: any): boolean { |
|
|
private getInitSelectable(rowData: any) { |
|
|
let selectable: any = true; |
|
|
let selectable: any = true; |
|
|
const this_ = this; |
|
|
const this_ = this; |
|
|
if (this_.props.selectMode === Constant.SELECT_MODE.NONE) { |
|
|
if (this_.props.selectMode === Constant.SELECT_MODE.NONE) { |
|
@ -401,8 +405,8 @@ export class RowData extends Base { |
|
|
} else if (this_.props.selectMode === Constant.SELECT_MODE.CELL) { |
|
|
} else if (this_.props.selectMode === Constant.SELECT_MODE.CELL) { |
|
|
if (this_.props.selectableIf && typeof this_.props.selectableIf === 'function') { |
|
|
if (this_.props.selectableIf && typeof this_.props.selectableIf === 'function') { |
|
|
selectable = {}; |
|
|
selectable = {}; |
|
|
let cellSelectable = false; |
|
|
|
|
|
for (let i = 0; i < this_.table.columns.length; i++) { |
|
|
for (let i = 0; i < this_.table.columns.length; i++) { |
|
|
|
|
|
let cellSelectable = false; |
|
|
const colName = this_.table.columns[i]['name']; |
|
|
const colName = this_.table.columns[i]['name']; |
|
|
if (colName !== Constant.FIELD_NAMES.SORT_NO) { |
|
|
if (colName !== Constant.FIELD_NAMES.SORT_NO) { |
|
|
const result = this_.props.selectableIf({ grid: this_.instance, data: rowData, colName }); |
|
|
const result = this_.props.selectableIf({ grid: this_.instance, data: rowData, colName }); |
|
@ -418,26 +422,60 @@ export class RowData extends Base { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据传入的行数据中的_selectable字段,判断该行数据是否可选。 |
|
|
* 获取树表格行数据初始化是否可勾选状态 |
|
|
* @param row |
|
|
* @param rowData |
|
|
|
|
|
*/ |
|
|
|
|
|
getInitTreeTickable(rowData: any) { |
|
|
|
|
|
const this_ = this; |
|
|
|
|
|
let tickable = true; |
|
|
|
|
|
if (this_.props.treeTickableIf && typeof this_.props.treeTickableIf === 'function') { |
|
|
|
|
|
const result = this_.props.treeTickableIf({ grid: this_.instance, data: rowData }); |
|
|
|
|
|
if (!result) { |
|
|
|
|
|
tickable = false; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return tickable; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据传入的行数据中的_selectable字段,判断是否可选。 |
|
|
|
|
|
* @param row 行数据 |
|
|
|
|
|
* @param colName 列名称 |
|
|
* @returns |
|
|
* @returns |
|
|
*/ |
|
|
*/ |
|
|
getRowSelectable(row) { |
|
|
getSelectable(row: any, colName?: string) { |
|
|
if (this.props.selectMode === Constant.SELECT_MODE.CELL && typeof row[Constant.FIELD_NAMES.SELECTABLE] === 'object') { |
|
|
if (this.props.selectMode === Constant.SELECT_MODE.CELL && typeof row[Constant.FIELD_NAMES.SELECTABLE] === 'object') { |
|
|
let selectable = true; |
|
|
if (colName) { |
|
|
|
|
|
return row[Constant.FIELD_NAMES.SELECTABLE][colName]; |
|
|
|
|
|
} |
|
|
|
|
|
let falseNumber = 0; |
|
|
const keys = Object.keys(row[Constant.FIELD_NAMES.SELECTABLE]); |
|
|
const keys = Object.keys(row[Constant.FIELD_NAMES.SELECTABLE]); |
|
|
for (let i = 0; i < keys.length; i++) { |
|
|
for (let i = 0; i < keys.length; i++) { |
|
|
if (row[Constant.FIELD_NAMES.SELECTABLE][keys[i]] === false) { |
|
|
if (row[Constant.FIELD_NAMES.SELECTABLE][keys[i]] === false) { |
|
|
selectable = false; |
|
|
falseNumber++; |
|
|
break; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return selectable; |
|
|
if (keys.length === falseNumber) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
return true; |
|
|
} else { |
|
|
} else { |
|
|
return row[Constant.FIELD_NAMES.SELECTABLE]; |
|
|
return row[Constant.FIELD_NAMES.SELECTABLE]; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据传入的行数据中的_treeTickable字段,判断是否可勾选。 |
|
|
|
|
|
* @param row 行数据 |
|
|
|
|
|
* @returns |
|
|
|
|
|
*/ |
|
|
|
|
|
getTreeTickable(row: any) { |
|
|
|
|
|
if (row[Constant.FIELD_NAMES.TREE_TICKABLE] === undefined || row[Constant.FIELD_NAMES.TREE_TICKABLE] === true) { |
|
|
|
|
|
return true; |
|
|
|
|
|
} |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取初始化行的ticked状态 |
|
|
* 获取初始化行的ticked状态 |
|
|
* @param rowData |
|
|
* @param rowData |
|
|