Skip to content

Commit b8f2aaa

Browse files
committed
fix: CDataTable restore loading functionality:
- add loading prop - when true display loadingSlot - default CElementCover displayed when loadingSlot not passed
1 parent 9a254db commit b8f2aaa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/CDataTable.js

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, useRef, useMemo } from 'react'
22
import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44
import CPagination from './CPagination'
5+
import CElementCover from './CElementCover'
56
import style from './CDataTable.module.css'
67
import { CIcon } from '@coreui/icons-react'
78
import { cilArrowTop, cilBan } from '@coreui/icons'
@@ -21,7 +22,9 @@ const CDataTable = props => {
2122
captionSlot,
2223
underTableSlot,
2324
theadTopSlot,
25+
loadingSlot,
2426
scopedSlots,
27+
loading,
2528
fields,
2629
pagination,
2730
activePage,
@@ -522,6 +525,15 @@ const CDataTable = props => {
522525
{ footer && currentItems.length > 0 && <tfoot>{headerContent}</tfoot>}
523526
{ captionSlot }
524527
</table>
528+
{ loading &&
529+
(loadingSlot ||
530+
<CElementCover
531+
boundaries={[
532+
{ sides: ['top'], query: 'td' },
533+
{ sides: ['bottom'], query: 'tbody' }
534+
]}
535+
/>)
536+
}
525537
</div>
526538

527539
{ underTableSlot }
@@ -552,6 +564,8 @@ CDataTable.propTypes = {
552564
underTableSlot: PropTypes.node,
553565
scopedSlots: PropTypes.object,
554566
theadTopSlot: PropTypes.node,
567+
loadingSlot: PropTypes.node,
568+
loading: PropTypes.bool,
555569
fields: PropTypes.array,
556570
pagination: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
557571
activePage: PropTypes.number,

0 commit comments

Comments
 (0)