Skip to content
This repository was archived by the owner on Jun 22, 2019. It is now read-only.

Column widths #32

Merged
merged 3 commits into from
Dec 22, 2017
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
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,26 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## 0.5.2
### Added
- A `column_widths` property can be used to set the column widths of the
`DataTable`. Simple example:
```python
ROWS = [
{'a': 'AA', 'b': 1},
{'a': 'AB', 'b': 2},
]

dt.DataTable(
rows=ROWS,
columns=['a', 'b'],
column_widths=[200, 400]
)
```

## 0.5.1
`datatable` now automatically resizes to fit data that has less than 10 rows.
### Added
- `DataTable` now automatically resizes to fit data that has less than 10 rows.

## 0.5.0
### Added
Expand Down
17 changes: 17 additions & 0 deletions dash_table_experiments/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@
"params": [],
"returns": null
},
{
"name": "getMinHeight",
"docblock": null,
"modifiers": [],
"params": [],
"returns": null
},
{
"name": "onRowsSelected",
"docblock": null,
Expand Down Expand Up @@ -169,6 +176,16 @@
"computed": false
}
},
"column_widths": {
"type": {
"name": "arrayOf",
"value": {
"name": "number"
}
},
"required": false,
"description": ""
},
"columns": {
"type": {
"name": "arrayOf",
Expand Down
2 changes: 1 addition & 1 deletion dash_table_experiments/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.5.1'
__version__ = '0.5.2'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table-experiments",
"version": "0.5.1",
"version": "0.5.2",
"description": "Dash table experiments",
"main": "lib/index.js",
"repository": {
Expand Down
7 changes: 7 additions & 0 deletions src/components/DataTable.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class DataTable extends Component {
sortable: Boolean(props.sortable),
filterable: Boolean(props.filterable)
}));
if (props.column_widths) {
newState.columns.forEach((c, i) => {
c.width = props.column_widths[i];
});
}

this.setState(newState);
}
Expand Down Expand Up @@ -322,6 +327,8 @@ DataTable.propTypes = {
editable: PropTypes.bool,
filterable: PropTypes.bool,
sortable: PropTypes.bool,
column_widths: PropTypes.arrayOf(PropTypes.number),

/**
* Order of columns. Note that the column names are specified in
* `rows` but without order. This attribute allows you to specify
Expand Down