Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[故障] 修复table的checkbox渲染器设置初始data会导致功能不可用,fixes #925 #926

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/demo/table/checkbox-column/demo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export class TableAddCheckboxColumnDemoComponent {
renderer: TableHeadCheckboxRenderer,
},
cell: {
renderer: TableCellCheckboxRenderer
renderer: TableCellCheckboxRenderer,
data: (td, row, col) => {
return td.data[row][2] == 'Developer'
}
}
}];

Expand Down
16 changes: 16 additions & 0 deletions src/jigsaw/component/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ export class JigsawTable extends AbstractJigsawComponent implements OnInit, Afte
return tableData.data[row][index];
}

private _updateAdditionalData(field: string, row: number, cellData: string) {
let [index, tableData] = this._getColumnIndex(field);
if (index == -1) {
console.error('no cell data found, unknown field: ' + field);
return;
}
if (!tableData.data[row]) {
tableData.data[row] = [];
}
if (tableData instanceof AdditionalTableData) {
tableData.data[row][index] = cellData;
}
}

/**
* @internal
*/
Expand Down Expand Up @@ -221,8 +235,10 @@ export class JigsawTable extends AbstractJigsawComponent implements OnInit, Afte
const cellDataGenerator = TableUtils.getGenerator(columnDefine, 'data');
if (cellDataGenerator) {
settings.cellData = cellDataGenerator(this.data, rowIndex, realColIndex, this._additionalData);
this._updateAdditionalData(field, rowIndex, settings.cellData);
} else if (columnDefine.cell && typeof columnDefine.cell.data == 'string') {
settings.cellData = columnDefine.cell.data;
this._updateAdditionalData(field, rowIndex, settings.cellData);
} else {
settings.cellData = this._getCellDataByField(field, rowIndex);
}
Expand Down