Skip to content

Commit

Permalink
column tilte property
Browse files Browse the repository at this point in the history
  • Loading branch information
sarzijan committed May 4, 2016
1 parent f43d265 commit e77bd32
Show file tree
Hide file tree
Showing 8 changed files with 416 additions and 345 deletions.
18 changes: 18 additions & 0 deletions __tests__/TableHeaderColumn-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('TableHeaderColumn Test', function() {
expect(idHeaderColumn.props.children).toEqual("Product ID");
expect(idHeaderColumn.props.dataAlign).toEqual("left");
expect(idHeaderColumn.props.dataSort).toEqual(false);
expect(idHeaderColumn.props.columnTitle).toEqual(false);
expect(idHeaderColumn.props.dataFormat).toBe(undefined);
expect(idHeaderColumn.props.isKey).toBe(true);

Expand Down Expand Up @@ -60,6 +61,7 @@ describe('TableHeaderColumn Test', function() {
expect(idHeaderColumn.props.children).toEqual("Product ID");
expect(idHeaderColumn.props.dataAlign).toEqual("center");
expect(idHeaderColumn.props.dataSort).toEqual(false);
expect(idHeaderColumn.props.columnTitle).toEqual(false);
expect(idHeaderColumn.props.dataFormat).toBe(undefined);
expect(idHeaderColumn.props.isKey).toBe(false);

Expand All @@ -77,6 +79,7 @@ describe('TableHeaderColumn Test', function() {
expect(idHeaderColumn.props.children).toEqual("Product ID");
expect(idHeaderColumn.props.dataAlign).toEqual("left");
expect(idHeaderColumn.props.dataSort).toEqual(false);
expect(idHeaderColumn.props.columnTitle).toEqual(false);
expect(idHeaderColumn.props.dataFormat).toBe(undefined);
expect(idHeaderColumn.props.isKey).toBe(true);
});
Expand All @@ -94,10 +97,25 @@ describe('TableHeaderColumn Test', function() {
expect(idHeaderColumn.props.children).toEqual("Product ID");
expect(idHeaderColumn.props.dataAlign).toEqual("left");
expect(idHeaderColumn.props.dataSort).toEqual(false);
expect(idHeaderColumn.props.columnTitle).toEqual(false);
expect(idHeaderColumn.props.dataFormat).toEqual(priceFormatter);
expect(idHeaderColumn.props.isKey).toBe(false);
});

it('A columnTitle header column test', function(){
var idHeaderColumn = TestUtils.renderIntoDocument(
<TableHeaderColumn dataField="id" columnTitle={ true }>Product ID</TableHeaderColumn>
);

expect(idHeaderColumn.props.dataField).toEqual("id");
expect(idHeaderColumn.props.children).toEqual("Product ID");
expect(idHeaderColumn.props.dataAlign).toEqual("left");
expect(idHeaderColumn.props.dataSort).toEqual(false);
expect(idHeaderColumn.props.columnTitle).toEqual(true);
expect(idHeaderColumn.props.dataFormat).toEqual(undefined);
expect(idHeaderColumn.props.isKey).toBe(false);
});

it('A sort header column test', function(){
var idHeaderColumn = TestUtils.renderIntoDocument(
<TableHeaderColumn dataField="id" dataSort={true}>Product ID</TableHeaderColumn>
Expand Down
720 changes: 382 additions & 338 deletions dist/react-bootstrap-table.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/react-bootstrap-table.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions dist/react-bootstrap-table.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class BootstrapTable extends Component {
hidden: column.props.hidden,
searchable: column.props.searchable,
className: column.props.columnClassName,
columnTitle: column.props.columnTitle,
width: column.props.width,
text: column.props.children,
sortFunc: column.props.sortFunc,
Expand Down
5 changes: 5 additions & 0 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class TableBody extends Component {
} else {
// add by bluespring for className customize
let columnChild = fieldValue;
let columnTitle = null;
let tdClassName = column.className;
if (isFun(column.className)) {
tdClassName = column.className(fieldValue, data, r, i);
Expand All @@ -76,12 +77,16 @@ class TableBody extends Component {
);
} else {
columnChild = formattedValue;
columnTitle = column.columnTitle ? formattedValue.toString() : null;
}
} else {
columnTitle = column.columnTitle ? fieldValue.toString() : null;
}
return (
<TableColumn key={ i }
dataAlign={ column.align }
className={ tdClassName }
columnTitle={ columnTitle }
cellEdit={ this.props.cellEdit }
hidden={ column.hidden }
onEdit={ this.handleEditCell }
Expand Down
3 changes: 2 additions & 1 deletion src/TableColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TableColumn extends Component {
}
}
return (
<td style={ tdStyle } className={ this.props.className } { ...opts }>
<td style={ tdStyle } title={ this.props.columnTitle } className={ this.props.className } { ...opts }>
{ this.props.children }
</td>
);
Expand All @@ -84,6 +84,7 @@ TableColumn.propTypes = {
dataAlign: PropTypes.string,
hidden: PropTypes.bool,
className: PropTypes.string,
columnTitle: PropTypes.string,
children: PropTypes.node
};

Expand Down
2 changes: 2 additions & 0 deletions src/TableHeaderColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ TableHeaderColumn.propTypes = {
sortFunc: PropTypes.func,
sortFuncExtraData: PropTypes.any,
columnClassName: PropTypes.any,
columnTitle: PropTypes.bool,
filterFormatted: PropTypes.bool,
sort: PropTypes.string,
caretRender: PropTypes.func,
Expand Down Expand Up @@ -159,6 +160,7 @@ TableHeaderColumn.defaultProps = {
hidden: false,
searchable: true,
className: '',
columnTitle: false,
width: null,
sortFunc: undefined,
columnClassName: '',
Expand Down

0 comments on commit e77bd32

Please sign in to comment.