khtruong commented on a change in pull request #7777: Truncate data that is
expanded
URL:
https://github.com/apache/incubator-superset/pull/7777#discussion_r297837598
##########
File path: superset/assets/src/components/FilterableTable/FilterableTable.jsx
##########
@@ -152,21 +153,32 @@ export default class FilterableTable extends
PureComponent {
const widthsByColumnKey = {};
this.props.orderedColumnKeys.forEach((key) => {
const colWidths = this.list
- .map(d => getTextWidth(d[key]) + PADDING) // get width for each value
for a key
- .push(getTextWidth(key) + PADDING); // add width of column key to end
of list
+ // get width for each value for a key
+ .map(d => getTextWidth(
+ this.getCellContent({ cellData: d[key], columnKey: key })) + PADDING,
+ )
+ // add width of column key to end of list
+ .push(getTextWidth(key) + PADDING);
// set max width as value for key
widthsByColumnKey[key] = Math.max(...colWidths);
});
return widthsByColumnKey;
}
- fitTableToWidthIfNeeded() {
- const containerWidth = this.container.clientWidth;
- if (this.totalTableWidth < containerWidth) {
- // fit table width if content doesn't fill the width of the container
- this.totalTableWidth = containerWidth;
+ getCellContent({ cellData, columnKey }) {
+ const complexColumn = this.props.expandedColumns.some(
+ name => name.startsWith(columnKey + '.'),
+ );
+ const content = String(cellData);
+ let type;
+ if (content.substring(0, 1) === '[') {
+ type = '[…]';
+ } else if (content.substring(0, 1) === '[') {
+ type = '{…}';
Review comment:
Sounds good. We can shorten this logic then.
const type = content.substring(0, 1) === '[' ? '[...]' : ''
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]