column新增`titleAlign`和`contentAlign`属性,控制标题和内容的居中

This commit is contained in:
huayj 2019-08-24 15:37:12 +08:00
parent ccdc64a61b
commit b7b4e2f8a3
3 changed files with 12 additions and 3 deletions

View File

@ -480,7 +480,8 @@ class Table extends Component {
fixed: column.fixed,
width: width,
dataindex:column.dataIndex,
textAlign:column.textAlign
textAlign:column.textAlign,
titleAlign: column.titleAlign, // 标题水平对齐方式
};
if (column.onHeadCellClick) {
cell.onClick = column.onHeadCellClick;

View File

@ -125,7 +125,10 @@ class TableCell extends Component{
if(column.fixed && !fixed){
className = className+` ${clsPrefix}-fixed-columns-in-body`;
}
if(column.textAlign){
if(column.contentAlign){
className = className+` text-${column.contentAlign}`;
}
else if(column.textAlign){
className = className+` text-${column.textAlign}`;
}
if(typeof text == 'string' && bodyDisplayInRow){

View File

@ -745,10 +745,15 @@ class TableHeader extends Component {
canDotDrag = "th-can-not-drag";
}
let thClassName = `${da.className}`?`${da.className}`:'';
if(da.textAlign){
if(da.titleAlign){
thClassName += ` text-${da.titleAlign} `;
}
else if(da.textAlign){
thClassName += ` text-${da.textAlign} `;
}
delete da.textAlign;
delete da.titleAlign;
const keyTemp = {};
//避免key为undefined
// if(da.dataindex && da.key ===undefined ){