Commit a4d36973 authored by zhangwenshuai's avatar zhangwenshuai

update showIndex

parent 74d527ed
...@@ -162,7 +162,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -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 { tableWidth = 0 } = this.state;
const { totalWidth, configWidth, defaultWidthLen } = this.memoizeTotalWidth(columns); const { totalWidth, configWidth, defaultWidthLen } = this.memoizeTotalWidth(columns);
const { columnWidth } = this.config; const { columnWidth } = this.config;
...@@ -170,7 +173,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -170,7 +173,7 @@ export default class AirTable extends Component<TableProps, TableState> {
if (totalWidth < tableWidth) { if (totalWidth < tableWidth) {
colWidth = _.floor((tableWidth - configWidth) / defaultWidthLen); colWidth = _.floor((tableWidth - configWidth) / defaultWidthLen);
} }
const columnObj = columns[index]; const columnObj = showColumns[index];
if (columnObj && columnObj.width) { if (columnObj && columnObj.width) {
return columnObj.width; return columnObj.width;
} }
...@@ -229,7 +232,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -229,7 +232,7 @@ export default class AirTable extends Component<TableProps, TableState> {
sortFlag={sortFlag} sortFlag={sortFlag}
sortConfig={sortConfig} sortConfig={sortConfig}
columnIndex={columnIndex} columnIndex={columnIndex}
showIndex={showIndex} showIndex={position === 'right' ? false : showIndex}
questionText={questionText} questionText={questionText}
rowSelection={position === 'right' ? false : rowSelection} rowSelection={position === 'right' ? false : rowSelection}
dataSource={dataSource} dataSource={dataSource}
...@@ -331,7 +334,7 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -331,7 +334,7 @@ export default class AirTable extends Component<TableProps, TableState> {
cellStyle={cellStyle} cellStyle={cellStyle}
columns={columns} columns={columns}
paginationConfig={paginationConfig} paginationConfig={paginationConfig}
showIndex={showIndex} showIndex={position === 'right' ? false : showIndex}
emptyPlaceholder={emptyPlaceholder} emptyPlaceholder={emptyPlaceholder}
cellEditable={cellEditable} cellEditable={cellEditable}
rowSelection={position === 'right' ? false : rowSelection} rowSelection={position === 'right' ? false : rowSelection}
...@@ -404,7 +407,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -404,7 +407,10 @@ export default class AirTable extends Component<TableProps, TableState> {
this.grid1 = dom; this.grid1 = dom;
}} }}
className={styles.headerGrid} className={styles.headerGrid}
columnWidth={this.getColumnWidth.bind(this, showColumns)} columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: leftColumns,
})}
columnCount={leftCount} columnCount={leftCount}
width={leftWidth} width={leftWidth}
rowHeight={headerHeight} rowHeight={headerHeight}
...@@ -435,7 +441,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -435,7 +441,10 @@ export default class AirTable extends Component<TableProps, TableState> {
showColumns: leftColumns, showColumns: leftColumns,
showData: leftData, showData: leftData,
})} })}
columnWidth={this.getColumnWidth.bind(this, showColumns)} columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: leftColumns,
})}
columnCount={leftCount} columnCount={leftCount}
width={leftWidth} width={leftWidth}
rowHeight={rowHeight} rowHeight={rowHeight}
...@@ -467,10 +476,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -467,10 +476,10 @@ export default class AirTable extends Component<TableProps, TableState> {
}} }}
className={styles.headerGrid} className={styles.headerGrid}
overscanColumnCount={overscanColumnCount} overscanColumnCount={overscanColumnCount}
columnWidth={this.getColumnWidth.bind( columnWidth={this.getColumnWidth.bind(this, {
this, columns: showColumns,
showColumns, showColumns,
)} })}
columnCount={columnCount} columnCount={columnCount}
width={width} width={width}
rowHeight={headerHeight} rowHeight={headerHeight}
...@@ -504,10 +513,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -504,10 +513,10 @@ export default class AirTable extends Component<TableProps, TableState> {
className={styles.centerGrid} className={styles.centerGrid}
overscanColumnCount={overscanColumnCount} overscanColumnCount={overscanColumnCount}
overscanRowCount={overscanRowCount} overscanRowCount={overscanRowCount}
columnWidth={this.getColumnWidth.bind( columnWidth={this.getColumnWidth.bind(this, {
this, columns: showColumns,
showColumns, showColumns,
)} })}
columnCount={columnCount} columnCount={columnCount}
width={realWidth} width={realWidth}
rowHeight={rowHeight} rowHeight={rowHeight}
...@@ -561,7 +570,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -561,7 +570,10 @@ export default class AirTable extends Component<TableProps, TableState> {
this.grid5 = dom; this.grid5 = dom;
}} }}
className={styles.headerGrid} className={styles.headerGrid}
columnWidth={this.getColumnWidth.bind(this, showColumns)} columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: rightColumns,
})}
columnCount={rightCount} columnCount={rightCount}
width={rightWidth} width={rightWidth}
rowHeight={headerHeight} rowHeight={headerHeight}
...@@ -595,7 +607,10 @@ export default class AirTable extends Component<TableProps, TableState> { ...@@ -595,7 +607,10 @@ export default class AirTable extends Component<TableProps, TableState> {
showData: rightData, showData: rightData,
position: 'right', position: 'right',
})} })}
columnWidth={this.getColumnWidth.bind(this, showColumns)} columnWidth={this.getColumnWidth.bind(this, {
columns: showColumns,
showColumns: rightColumns,
})}
columnCount={rightCount} columnCount={rightCount}
width={rightWidth} width={rightWidth}
rowHeight={rowHeight} 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