Skip to content

Commit

Permalink
Merge pull request #325 from komarovalexander/dev
Browse files Browse the repository at this point in the history
Add column.isFilterable option
  • Loading branch information
komarovalexander authored May 17, 2023
2 parents d007a6b + 3e8c7d9 commit 0a8e98c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ka-table",
"version": "8.0.1",
"version": "8.1.2",
"license": "MIT",
"repository": "github:komarovalexander/ka-table",
"homepage": "https://komarovalexander.github.io/ka-table/#/overview",
Expand Down
8 changes: 1 addition & 7 deletions src/Demos/SelectionDemo/SelectionDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const SelectionDemo: React.FC = () => {
columns={[
{
key: 'selection-cell',
isFilterable: false,
},
{ key: 'column1', title: 'Column 1', dataType: DataType.String },
{ key: 'column2', title: 'Column 2', dataType: DataType.String },
Expand All @@ -84,13 +85,6 @@ const SelectionDemo: React.FC = () => {
}
},
},
filterRowCell: {
content: (props) => {
if (props.column.key === 'selection-cell') {
return <></>;
}
},
},
headCell: {
content: (props) => {
if (props.column.key === 'selection-cell') {
Expand Down
23 changes: 13 additions & 10 deletions src/lib/Components/FilterCell/FilterCell.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import * as React from 'react';

import defaultOptions from '../../defaultOptions';
import FilterRowDataType from '../FilterRowDataType/FilterRowDataType';
import { IFilterRowEditorProps } from '../../props';
import defaultOptions from '../../defaultOptions';
import { getElementCustomization } from '../../Utils/ComponentUtils';
import FilterRowDataType from '../FilterRowDataType/FilterRowDataType';

const FilterCell: React.FunctionComponent<IFilterRowEditorProps> = (props) => {
const {
childComponents,
column: { style },
column,
} = props;
const { elementAttributes, content } = getElementCustomization({
className: `${defaultOptions.css.theadCell} ka-filter-row-cell ${defaultOptions.css.theadBackground} ${defaultOptions.css.theadFixed}`,
style
style: column.style
}, props, childComponents.filterRowCell);

return (
<td {...elementAttributes}>
{
content ? content :
(
<FilterRowDataType
{...props}
/>
)
column.isFilterable === false
? <></>
: content
? content
: (
<FilterRowDataType
{...props}
/>
)
}
</td>
);
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Models/Column.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DataType, SortDirection } from '../enums';

import { Field } from '../types';
import { PopupPosition } from './PopupPosition';

Expand All @@ -12,6 +13,7 @@ export class Column {
public headerFilterPopupPosition?: PopupPosition;
public isHeaderFilterPopupShown?: boolean;
public isEditable?: boolean;
public isFilterable?: boolean;
public isResizable?: boolean;
public isSortable?: boolean;
public key!: string;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Utils/HeadRowUtils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SortDirection, SortingMode } from '../enums';
import { isMultipleSorting, isSortingEnabled, isTripleStateSorting, sortColumns } from './SortUtils';
import { isMultipleSorting, isTripleStateSorting, sortColumns } from './SortUtils';

import { Column } from '../Models/Column';
import defaultOptions from '../defaultOptions';

export const getHeadCellClassName = (sortingMode: SortingMode, isGrouped?: boolean) => `${defaultOptions.css.theadCell} ${defaultOptions.css.theadCellHeight} ${defaultOptions.css.theadFixed} ${defaultOptions.css.theadBackground} ${isSortingEnabled(sortingMode) ? 'ka-pointer' : ''} ${isGrouped ? 'ka-thead-grouped-cell' : ''}`
export const getHeadCellClassName = (sortingMode: SortingMode, isGrouped?: boolean) => `${defaultOptions.css.theadCell} ${defaultOptions.css.theadCellHeight} ${defaultOptions.css.theadFixed} ${defaultOptions.css.theadBackground} ${isGrouped ? 'ka-thead-grouped-cell' : ''}`

export const getUpdatedSortedColumns = (
columns: Column[],
Expand Down

0 comments on commit 0a8e98c

Please sign in to comment.