Commit a4d36973 authored by zhangwenshuai's avatar zhangwenshuai

update showIndex

parent 74d527ed
......@@ -162,7 +162,10 @@ export default class AirTable extends Component<TableProps, TableState> {
};
// 获取每列的宽度
getColumnWidth = (columns: ColumnProps[], { index }: { index: number }) => {
getColumnWidth = (
{ columns, showColumns }: { columns: ColumnProps[]; showColumns: ColumnProps[] },
{ index }: { index: number },
) => {
const { tableWidth = 0 } = this.state;
const { totalWidth, configWidth, defaultWidthLen } = this.memoizeTotalWidth(columns);
const { columnWidth } = this.config;
......@@ -170,7 +173,7 @@ export default class AirTable extends Component<TableProps, TableState> {
if (totalWidth < tableWidth) {
colWidth = _.floor((tableWidth - configWidth) / defaultWidthLen);
}
const columnObj = columns[index];
const columnObj = showColumns[index];
if (columnObj && columnObj.width) {
return columnObj.width;
}
......@@ -229,7 +232,7 @@ export default class AirTable extends Component<TableProps, TableState> {
sortFlag={sortFlag}
sortConfig={sortConfig}
columnIndex={columnIndex}
showIndex={showIndex}
showIndex={position === 'right' ? false : showIndex}
questionText={questionText}
rowSelection={position === 'right' ? false : rowSelection}
dataSource={dataSource}
......@@ -331,7 +334,7 @@ export default class AirTable extends Component<TableProps, TableState> {
cellStyle={cellStyle}
columns={columns}
paginationConfig={paginationConfig}
showIndex={showIndex}
showIndex={position === 'right' ? false : showIndex}
emptyPlaceholder={emptyPlaceholder}
cellEditable={cellEditable}
rowSelection={position === 'right' ? false : rowSelection}
......@@ -404,7 +407,10 @@ export default class AirTable extends Component<TableProps, TableState> {
this.grid1 = dom;
}}
className={styles.headerGrid}
columnWidth={this.getColumnWidth.bind(this, showColumns)}
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: leftColumns,
})}
columnCount={leftCount}
width={leftWidth}
rowHeight={headerHeight}
......@@ -435,7 +441,10 @@ export default class AirTable extends Component<TableProps, TableState> {
showColumns: leftColumns,
showData: leftData,
})}
columnWidth={this.getColumnWidth.bind(this, showColumns)}
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: leftColumns,
})}
columnCount={leftCount}
width={leftWidth}
rowHeight={rowHeight}
......@@ -467,10 +476,10 @@ export default class AirTable extends Component<TableProps, TableState> {
}}
className={styles.headerGrid}
overscanColumnCount={overscanColumnCount}
columnWidth={this.getColumnWidth.bind(
this,
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns,
)}
})}
columnCount={columnCount}
width={width}
rowHeight={headerHeight}
......@@ -504,10 +513,10 @@ export default class AirTable extends Component<TableProps, TableState> {
className={styles.centerGrid}
overscanColumnCount={overscanColumnCount}
overscanRowCount={overscanRowCount}
columnWidth={this.getColumnWidth.bind(
this,
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns,
)}
})}
columnCount={columnCount}
width={realWidth}
rowHeight={rowHeight}
......@@ -561,7 +570,10 @@ export default class AirTable extends Component<TableProps, TableState> {
this.grid5 = dom;
}}
className={styles.headerGrid}
columnWidth={this.getColumnWidth.bind(this, showColumns)}
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: rightColumns,
})}
columnCount={rightCount}
width={rightWidth}
rowHeight={headerHeight}
......@@ -595,7 +607,10 @@ export default class AirTable extends Component<TableProps, TableState> {
showData: rightData,
position: 'right',
})}
columnWidth={this.getColumnWidth.bind(this, showColumns)}
columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: rightColumns,
})}
columnCount={rightCount}
width={rightWidth}
rowHeight={rowHeight}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment