mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
clear filter button
This commit is contained in:
parent
e8733c6587
commit
74e7d7d4e8
@ -338,4 +338,16 @@ export abstract class GridDisplay {
|
|||||||
});
|
});
|
||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get filterCount() {
|
||||||
|
return _.compact(_.values(this.config.filters)).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearFilters() {
|
||||||
|
this.setConfig({
|
||||||
|
...this.config,
|
||||||
|
filters: {},
|
||||||
|
});
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,8 @@ export default function DataFilterControl({ isReadOnly = false, filterType, filt
|
|||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
editorRef.current.value = filter || '';
|
editorRef.current.value = filter || '';
|
||||||
}, []);
|
updateFilterState();
|
||||||
|
}, [filter]);
|
||||||
|
|
||||||
const handleShowMenu = () => {
|
const handleShowMenu = () => {
|
||||||
const rect = buttonRef.current.getBoundingClientRect();
|
const rect = buttonRef.current.getBoundingClientRect();
|
||||||
|
@ -312,12 +312,20 @@ export default function DataGridCore(props) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hederColwidthPx = '40px';
|
||||||
|
const filterCount = display.filterCount;
|
||||||
|
|
||||||
|
const handleClearFilters = () => {
|
||||||
|
display.clearFilters();
|
||||||
|
};
|
||||||
|
|
||||||
// console.log('visibleRealColumnIndexes', visibleRealColumnIndexes);
|
// console.log('visibleRealColumnIndexes', visibleRealColumnIndexes);
|
||||||
return (
|
return (
|
||||||
<GridContainer ref={containerRef}>
|
<GridContainer ref={containerRef}>
|
||||||
<Table>
|
<Table>
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableHeaderRow ref={headerRowRef}>
|
<TableHeaderRow ref={headerRowRef}>
|
||||||
|
<TableHeaderCell />
|
||||||
{realColumns.map(col => (
|
{realColumns.map(col => (
|
||||||
<TableHeaderCell
|
<TableHeaderCell
|
||||||
key={col.uniqueName}
|
key={col.uniqueName}
|
||||||
@ -328,6 +336,13 @@ export default function DataGridCore(props) {
|
|||||||
))}
|
))}
|
||||||
</TableHeaderRow>
|
</TableHeaderRow>
|
||||||
<TableHeaderRow>
|
<TableHeaderRow>
|
||||||
|
<TableHeaderCell style={{ width: hederColwidthPx, minWidth: hederColwidthPx, maxWidth: hederColwidthPx }}>
|
||||||
|
{filterCount > 0 && (
|
||||||
|
<button onClick={handleClearFilters}>
|
||||||
|
<i className="fas fa-times" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</TableHeaderCell>
|
||||||
{realColumns.map(col => (
|
{realColumns.map(col => (
|
||||||
<TableFilterCell
|
<TableFilterCell
|
||||||
key={col.uniqueName}
|
key={col.uniqueName}
|
||||||
@ -347,6 +362,7 @@ export default function DataGridCore(props) {
|
|||||||
.slice(firstVisibleRowScrollIndex, firstVisibleRowScrollIndex + visibleRowCountUpperBound)
|
.slice(firstVisibleRowScrollIndex, firstVisibleRowScrollIndex + visibleRowCountUpperBound)
|
||||||
.map((row, index) => (
|
.map((row, index) => (
|
||||||
<TableBodyRow key={firstVisibleRowScrollIndex + index}>
|
<TableBodyRow key={firstVisibleRowScrollIndex + index}>
|
||||||
|
<TableHeaderCell>{firstVisibleRowScrollIndex + index + 1}</TableHeaderCell>
|
||||||
{realColumns.map(col => (
|
{realColumns.map(col => (
|
||||||
<TableBodyCell
|
<TableBodyCell
|
||||||
key={col.uniqueName}
|
key={col.uniqueName}
|
||||||
|
Loading…
Reference in New Issue
Block a user