Skip to content

Commit ecd9fc3

Browse files
committed
Add fixed last column option to data-grid Table
1 parent 8876163 commit ecd9fc3

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

packages/data-grid/src/table/Table.jsx

+5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ const propTypes = {
7171
horizontalScroll: bool,
7272
/** Optional boolean to cause the first column to be fixed when horizontalScrool is true */
7373
fixedColumn: bool,
74+
/** Optional boolean to cause the first column to be fixed when horizontalScrool is true */
75+
fixedLastColumn: bool,
7476
/** Optional string to provider header which is visable when no data is available */
7577
emptyStateHeader: string,
7678
/** Optional string to provider descriptive message explaining the empty state of the table */
@@ -96,6 +98,7 @@ const defaultProps = {
9698
sortedColumn: { direction: '', sortDataKey: '' },
9799
horizontalScroll: false,
98100
fixedColumn: false,
101+
fixedLastColumn: false,
99102
emptyStateHeader: 'No data available',
100103
emptyStateMessage: 'Prompt to action or solution',
101104
loading: false,
@@ -158,6 +161,7 @@ class Table extends Component {
158161
loading,
159162
loadingMessage,
160163
fixedColumn,
164+
fixedLastColumn,
161165
horizontalScroll,
162166
emptyStateHeader,
163167
emptyStateMessage,
@@ -181,6 +185,7 @@ class Table extends Component {
181185
className={classnames({
182186
'dg-table-horizontal-scroll': horizontalScroll,
183187
'dg-table-fixed-column': fixedColumn,
188+
'dg-table-fixed-last-column': fixedLastColumn,
184189
})}
185190
>
186191
<table

packages/data-grid/src/table/Table.scss

+28-9
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,41 @@
9393
border-collapse: separate;
9494
border-spacing: 0;
9595

96-
th:first-child {
97-
position: -webkit-sticky;
98-
position: sticky;
99-
left: 0;
100-
z-index: 2;
96+
th,
97+
td {
98+
:first-child {
99+
position: -webkit-sticky;
100+
position: sticky;
101+
left: 0;
102+
z-index: 2;
103+
}
101104
}
102105

103106
td:first-child {
104-
position: -webkit-sticky;
105-
position: sticky;
106-
left: 0;
107-
z-index: 2;
108107
background-color: $puppet-n200;
109108
}
110109
}
111110

111+
.dg-table-fixed-last-column {
112+
width: 100%;
113+
border-collapse: separate;
114+
border-spacing: 0;
115+
116+
th,
117+
td {
118+
:last-child {
119+
position: -webkit-sticky;
120+
position: sticky;
121+
right: 0;
122+
z-index: 2;
123+
}
124+
}
125+
126+
td:last-child {
127+
background-color: $puppet-white;
128+
}
129+
}
130+
112131
/** Loading State **/
113132

114133
.dg-table-loading-container {

0 commit comments

Comments
 (0)