File tree Expand file tree Collapse file tree 7 files changed +42
-1
lines changed
apps/material-react-table-docs
examples/enable-column-pinning/sandbox/src
packages/material-react-table Expand file tree Collapse file tree 7 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -522,6 +522,28 @@ export const tableOptions: TableOption[] = [
522522 source : '' ,
523523 type : 'boolean' ,
524524 } ,
525+ {
526+ tableOption : 'enableColumnResetPins' ,
527+ defaultValue : '' ,
528+ description :
529+ "Determines if 'Reset Pins' option is available in the Show/Hide columns menu." ,
530+ link : '/docs/guides/column-pinning#column-resize-mode' ,
531+ linkText : 'MRT Column Pinning Docs' ,
532+ required : false ,
533+ source : 'MRT' ,
534+ type : 'boolean' ,
535+ } ,
536+ {
537+ tableOption : 'enableColumnUnpinAll' ,
538+ defaultValue : 'true' ,
539+ description :
540+ "Determines if 'Unpin All' option is available in the Show/Hide columns menu." ,
541+ link : '/docs/guides/column-pinning#column-resize-mode' ,
542+ linkText : 'MRT Column Pinning Docs' ,
543+ required : false ,
544+ source : 'MRT' ,
545+ type : 'boolean' ,
546+ } ,
525547 {
526548 tableOption : 'enableCellActions' ,
527549 defaultValue : '' ,
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ const Example = () => {
5555 columns,
5656 data,
5757 enableColumnPinning : true ,
58+ enableColumnResetPins : true ,
5859 enableRowActions : true ,
5960 layoutMode : 'grid-no-grow' , //constant column widths
6061 renderRowActionMenuItems : ( ) => [ < MenuItem key = "action" > Action</ MenuItem > ] ,
Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
3939 options : {
4040 enableColumnOrdering,
4141 enableColumnPinning,
42+ enableColumnResetPins,
43+ enableColumnUnpinAll,
4244 enableHiding,
4345 localization,
4446 mrtTheme : { menuBackgroundColor } ,
@@ -136,14 +138,21 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
136138 { localization . resetOrder }
137139 </ Button >
138140 ) }
139- { enableColumnPinning && (
141+ { enableColumnPinning && enableColumnUnpinAll && (
140142 < Button
141143 disabled = { ! getIsSomeColumnsPinned ( ) }
142144 onClick = { ( ) => table . resetColumnPinning ( true ) }
143145 >
144146 { localization . unpinAll }
145147 </ Button >
146148 ) }
149+ { enableColumnPinning && enableColumnResetPins && (
150+ < Button
151+ onClick = { ( ) => table . resetColumnPinning ( ) }
152+ >
153+ { localization . resetPins }
154+ </ Button >
155+ ) }
147156 { enableHiding && (
148157 < Button
149158 disabled = { getIsAllColumnsVisible ( ) }
Original file line number Diff line number Diff line change @@ -63,7 +63,9 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
6363 enableColumnFilters = true ,
6464 enableColumnOrdering = false ,
6565 enableColumnPinning = false ,
66+ enableColumnResetPins = false ,
6667 enableColumnResizing = false ,
68+ enableColumnUnpinAll = true ,
6769 enableColumnVirtualization,
6870 enableDensityToggle = true ,
6971 enableExpandAll = true ,
@@ -192,7 +194,9 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
192194 enableColumnFilters,
193195 enableColumnOrdering,
194196 enableColumnPinning,
197+ enableColumnResetPins,
195198 enableColumnResizing,
199+ enableColumnUnpinAll,
196200 enableColumnVirtualization,
197201 enableDensityToggle,
198202 enableExpandAll,
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ export const MRT_Localization_EN: MRT_Localization = {
6767 pinToRight : 'Pin to right' ,
6868 resetColumnSize : 'Reset column size' ,
6969 resetOrder : 'Reset order' ,
70+ resetPins : 'Reset pins' ,
7071 rowActions : 'Row Actions' ,
7172 rowNumber : '#' ,
7273 rowNumbers : 'Row Numbers' ,
Original file line number Diff line number Diff line change @@ -217,6 +217,7 @@ export interface MRT_Localization {
217217 pinToRight : string ;
218218 resetColumnSize : string ;
219219 resetOrder : string ;
220+ resetPins : string ;
220221 rowActions : string ;
221222 rowNumber : string ;
222223 rowNumbers : string ;
@@ -862,6 +863,8 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
862863 enableColumnDragging ?: boolean ;
863864 enableColumnFilterModes ?: boolean ;
864865 enableColumnOrdering ?: boolean ;
866+ enableColumnResetPins ?: boolean ;
867+ enableColumnUnpinAll ?: boolean ;
865868 enableColumnVirtualization ?: boolean ;
866869 enableDensityToggle ?: boolean ;
867870 enableEditing ?: ( ( row : MRT_Row < TData > ) => boolean ) | boolean ;
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ export const ColumnPinningInitial = () => (
5353 columns = { columns }
5454 data = { data }
5555 enableColumnPinning
56+ enableColumnResetPins
5657 initialState = { { columnPinning : { left : [ 'email' ] , right : [ 'state' ] } } }
5758 />
5859) ;
You can’t perform that action at this time.
0 commit comments