99 LoadingTypeEnum ,
1010 PaginationEnum ,
1111 PagingPositionEnum ,
12- SelectionCountVisibilityEnum ,
12+ SelectionCountPositionEnum ,
1313 ShowPagingButtonsEnum
1414} from "../../typings/DatagridProps" ;
1515import { SelectActionHelper } from "../helpers/SelectActionHelper" ;
@@ -26,6 +26,7 @@ import { WidgetFooter } from "./WidgetFooter";
2626import { WidgetHeader } from "./WidgetHeader" ;
2727import { WidgetRoot } from "./WidgetRoot" ;
2828import { WidgetTopBar } from "./WidgetTopBar" ;
29+ import { SelectionCounter } from "./SelectionCounter" ;
2930
3031export interface WidgetProps < C extends GridColumn , T extends ObjectItem = ObjectItem > {
3132 CellComponent : CellComponent < C > ;
@@ -49,8 +50,7 @@ export interface WidgetProps<C extends GridColumn, T extends ObjectItem = Object
4950 page : number ;
5051 paginationType : PaginationEnum ;
5152 loadMoreButtonCaption ?: string ;
52- clearSelectionButtonLabel ?: string ;
53- selectionCountVisibility ?: SelectionCountVisibilityEnum ;
53+ selectionCountPosition ?: SelectionCountPositionEnum ;
5454 pageSize : number ;
5555 paging : boolean ;
5656 pagingPosition : PagingPositionEnum ;
@@ -121,8 +121,7 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
121121 headerContent,
122122 headerTitle,
123123 loadMoreButtonCaption,
124- clearSelectionButtonLabel,
125- selectionCountVisibility,
124+ selectionCountPosition,
126125 numberOfItems,
127126 page,
128127 pageSize,
@@ -139,8 +138,8 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
139138 const { basicData, selectionCountStore } = useDatagridRootScope ( ) ;
140139
141140 const showHeader = ! ! headerContent ;
142- const showTopBar = paging && ( pagingPosition === "top" || pagingPosition === "both" ) ;
143- const showFooter = paging && ( pagingPosition === "bottom" || pagingPosition === "both" ) ;
141+ const showTopBarPagination = paging && ( pagingPosition === "top" || pagingPosition === "both" ) ;
142+ const showFooterPagination = paging && ( pagingPosition === "bottom" || pagingPosition === "both" ) ;
144143
145144 const pagination = paging ? (
146145 < Pagination
@@ -157,6 +156,14 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
157156 />
158157 ) : null ;
159158
159+ const selectionCount =
160+ selectionCountStore . selectedCount > 0 && selectionCountPosition !== "off" && selectionCountPosition ? (
161+ < SelectionCounter location = { selectionCountPosition } />
162+ ) : null ;
163+
164+ const showTopbarSelectionCount = selectionCount && selectionCountPosition === "top" ;
165+ const showFooterSelectionCount = selectionCount && selectionCountPosition === "bottom" ;
166+
160167 const cssGridStyles = gridStyle ( visibleColumns , {
161168 selectItemColumn : selectActionHelper . showCheckboxColumn ,
162169 visibilitySelectorColumn : columnsHidable
@@ -167,13 +174,9 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
167174 return (
168175 < Fragment >
169176 < WidgetTopBar
170- selectedCount = { selectionCountStore . selectedCount }
171- showTopBar = { showTopBar }
172- selectionCountVisibility = { selectionCountVisibility }
173- clearSelectionButtonLabel = { clearSelectionButtonLabel }
174- >
175- { pagination }
176- </ WidgetTopBar >
177+ pagination = { showTopBarPagination ? pagination : undefined }
178+ selectionCount = { showTopbarSelectionCount ? selectionCount : undefined }
179+ > </ WidgetTopBar >
177180 { showHeader && < WidgetHeader headerTitle = { headerTitle } > { headerContent } </ WidgetHeader > }
178181 < WidgetContent >
179182 < Grid
@@ -244,13 +247,10 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
244247 </ Grid >
245248 </ WidgetContent >
246249 < WidgetFooter
247- selectedCount = { selectionCountStore . selectedCount }
248- showFooter = { showFooter }
249- pagination = { pagination }
250+ pagination = { showFooterPagination ? pagination : undefined }
251+ selectionCount = { showFooterSelectionCount ? selectionCount : undefined }
250252 paginationType = { paginationType }
251253 loadMoreButtonCaption = { loadMoreButtonCaption }
252- clearSelectionButtonLabel = { clearSelectionButtonLabel }
253- selectionCountVisibility = { selectionCountVisibility }
254254 hasMoreItems = { hasMoreItems }
255255 setPage = { setPage }
256256 />
0 commit comments