Skip to content
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
2 changes: 2 additions & 0 deletions packages/common/constants/HeaderRowType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const HEADER = 'header';
export const FILTER = 'filter';
2 changes: 2 additions & 0 deletions packages/common/constants/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as CellNavigationMode from './CellNavigationMode';
import * as EventTypes from './EventTypes';
import * as HeaderRowType from './HeaderRowType';
import keyMirror from 'keymirror';


Expand All @@ -23,6 +24,7 @@ const CellExpand = {
export {
CellNavigationMode,
EventTypes,
HeaderRowType,
UpdateActions,
CellExpand,
DragItemTypes
Expand Down
3 changes: 2 additions & 1 deletion packages/react-data-grid-addons/src/data/RowGrouper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class RowGrouper {
groupRowsByColumn(rows, columnIndex = 0) {
let nextColumnIndex = columnIndex;
let columnName = this.columns.length > 0 && typeof this.columns[columnIndex] === 'string' ? this.columns[columnIndex] : this.columns[columnIndex].key;
const columnGroupDisplayName = this.columns.length > 0 && typeof this.columns[columnIndex] === 'string' ? this.columns[columnIndex] : this.columns[columnIndex].name;
let groupedRows = this.resolver.getGroupedRows(rows, columnName);
let keys = this.resolver.getGroupKeys(groupedRows);
let dataviewRows = this.resolver.initRowsCollection();

for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let isExpanded = this.isRowExpanded(columnName, key);
let rowGroupHeader = {name: key, __metaData: {isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName}};
let rowGroupHeader = {name: key, __metaData: {isGroup: true, treeDepth: columnIndex, isExpanded: isExpanded, columnGroupName: columnName, columnGroupDisplayName}};
Copy link
Collaborator Author

@amanmahajan7 amanmahajan7 Oct 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this to show column.name instead of column.key in the group row


dataviewRows = this.resolver.addHeaderRow(rowGroupHeader, dataviewRows);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
import { DragSource } from 'react-dnd';
import React, {Component} from 'react';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { DragItemTypes } from 'common/constants';

class DraggableHeaderCell extends Component {

componentDidMount() {
let connectDragPreview = this.props.connectDragPreview;
let img = new Image();
const { connectDragPreview } = this.props;
const img = new Image();
img.src = './assets/images/drag_column_full.png';
img.onload = function() {
connectDragPreview(img);
};
}

setScrollLeft(scrollLeft) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer required as HeaderCell content is wrapped inside a DraggableHeaderCell

if (this.node) {
node.style.webkitTransform = `translate3d(${scrollLeft}px, 0px, 0px)`;
node.style.transform = `translate3d(${scrollLeft}px, 0px, 0px)`;
}
img.onload = () => connectDragPreview(img);
}

render() {
const { connectDragSource, isDragging} = this.props;
const { connectDragSource, isDragging } = this.props;
if (isDragging) {
return null;
}
return connectDragSource(<div ref={node => this.node = node} style={{cursor: 'move'}}>{this.props.renderHeaderCell(this.props)}</div>);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renderHeaderCell is not passed as a prop

return connectDragSource(<div style={{ cursor: 'move' }}>{this.props.children}</div>);
}
}

DraggableHeaderCell.propTypes = {
connectDragSource: PropTypes.func.isRequired,
connectDragPreview: PropTypes.func.isRequired,
isDragging: PropTypes.bool.isRequired,
renderHeaderCell: PropTypes.func.isRequired
children: PropTypes.element.isRequired
};

function collect(connect, monitor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ class RowRenderer extends React.Component {
renderBaseRow: PropTypes.func.isRequired
};

setScrollLeft = (scrollBy) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required as we introduced renderBaseRow

// if you want freeze columns to work, you need to make sure you implement this as apass through
this.row.setScrollLeft(scrollBy);
};

getRowStyle = () => {
return {
color: this.getRowBackground()
Expand Down
Loading