@@ -718,15 +718,22 @@ export const columnHeadersSelectionExtenderMixin = (Base: ModuleType<ColumnHeade
718718 this . _selectionController . selectionChanged . add ( this . _updateSelectAllValue . bind ( this ) ) ;
719719 }
720720
721+ private _isSelectAllCheckBoxVisible ( ) {
722+ const isEmptyData = this . _dataController . isEmpty ( ) ;
723+ const allowSelectAll = this . option ( 'selection.allowSelectAll' ) ;
724+ const isSelectAll = this . _selectionController . isSelectAll ( ) ;
725+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
726+ return ! isEmptyData && ( allowSelectAll || isSelectAll !== false ) ;
727+ }
728+
721729 private _updateSelectAllValue ( ) {
722730 const that = this ;
723731 const $element = that . element ( ) ;
724732 const $editor = $element && $element . find ( `.${ SELECT_CHECKBOX_CLASS } ` ) ;
725733
726- if ( $element && $editor . length && that . option ( 'selection.mode' ) === 'multiple' ) {
727- const selectAllValue = that . _selectionController . isSelectAll ( ) ;
728- const hasSelection = selectAllValue !== false ;
729- const isVisible = that . option ( 'selection.allowSelectAll' ) ? ! that . _dataController . isEmpty ( ) : hasSelection ;
734+ if ( $element && $editor . length && this . option ( 'selection.mode' ) === 'multiple' ) {
735+ const selectAllValue = this . _selectionController . isSelectAll ( ) ;
736+ const isVisible = this . _isSelectAllCheckBoxVisible ( ) ;
730737
731738 $editor . dxCheckBox ( 'instance' ) . option ( {
732739 visible : isVisible ,
@@ -758,8 +765,6 @@ export const columnHeadersSelectionExtenderMixin = (Base: ModuleType<ColumnHeade
758765 protected _createSelectAllCheckboxElement (
759766 column ?: Column ,
760767 ) : dxElementWrapper {
761- const isEmptyData = this . _dataController . isEmpty ( ) ;
762-
763768 const $groupElement = $ ( '<div>' )
764769 . addClass ( SELECT_CHECKBOX_CLASS ) ;
765770
@@ -770,8 +775,7 @@ export const columnHeadersSelectionExtenderMixin = (Base: ModuleType<ColumnHeade
770775 dataType : 'boolean' ,
771776 value : this . _selectionController . isSelectAll ( ) ,
772777 editorOptions : {
773- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
774- visible : ! isEmptyData && ( this . option ( 'selection.allowSelectAll' ) || this . _selectionController . isSelectAll ( ) !== false ) ,
778+ visible : this . _isSelectAllCheckBoxVisible ( ) ,
775779 } ,
776780 // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
777781 tabIndex : this . option ( 'useLegacyKeyboardNavigation' ) ? - 1 : this . option ( 'tabIndex' ) || 0 ,
@@ -801,6 +805,11 @@ export const columnHeadersSelectionExtenderMixin = (Base: ModuleType<ColumnHeade
801805 eventsEngine . on ( $element , clickEventName , this . createAction ( ( e ) => {
802806 const { event } = e ;
803807
808+ if ( ! this . _isSelectAllCheckBoxVisible ( ) ) {
809+ event . preventDefault ( ) ;
810+ return ;
811+ }
812+
804813 if ( ! $ ( event . target ) . closest ( `.${ SELECT_CHECKBOX_CLASS } ` ) . length ) {
805814 // @ts -expect-error
806815 eventsEngine . trigger ( $ ( event . currentTarget ) . children ( `.${ SELECT_CHECKBOX_CLASS } ` ) , clickEventName ) ;
0 commit comments