datagrid context menu

This commit is contained in:
Jan Prochazka 2020-11-19 12:42:13 +01:00
parent 682f53881d
commit 9a2520a10a
5 changed files with 40 additions and 25 deletions

View File

@ -58,6 +58,7 @@ export abstract class GridDisplay {
filterable = false;
editable = false;
isLoadedCorrectly = true;
supportsReload = false;
setColumnVisibility(uniquePath: string[], isVisible: boolean) {
const uniqueName = uniquePath.join('.');

View File

@ -32,6 +32,7 @@ export class TableGridDisplay extends GridDisplay {
this.filterable = true;
this.sortable = true;
this.editable = true;
this.supportsReload = true;
this.baseTable = this.table;
if (this.table && this.table.columns) {
this.changeSetKeyFields = this.table.primaryKey

View File

@ -17,6 +17,7 @@ export class ViewGridDisplay extends GridDisplay {
this.filterable = true;
this.sortable = true;
this.editable = false;
this.supportsReload = true;
}
getDisplayColumns(view: ViewInfo) {

View File

@ -15,30 +15,42 @@ export default function DataGridContextMenu({
}) {
return (
<>
<DropDownMenuItem onClick={reload} keyText="F5">
Reload
</DropDownMenuItem>
<DropDownMenuDivider />
{!!reload && (
<DropDownMenuItem onClick={reload} keyText="F5">
Reload
</DropDownMenuItem>
)}
{!!reload && <DropDownMenuDivider />}
<DropDownMenuItem onClick={copy} keyText="Ctrl+C">
Copy
</DropDownMenuItem>
<DropDownMenuItem onClick={revertRowChanges} keyText="Ctrl+R">
Revert row changes
</DropDownMenuItem>
<DropDownMenuItem onClick={deleteSelectedRows} keyText="Ctrl+Delete">
Delete selected rows
</DropDownMenuItem>
<DropDownMenuItem onClick={insertNewRow} keyText="Insert">
Insert new row
</DropDownMenuItem>
{revertRowChanges && (
<DropDownMenuItem onClick={revertRowChanges} keyText="Ctrl+R">
Revert row changes
</DropDownMenuItem>
)}
{deleteSelectedRows && (
<DropDownMenuItem onClick={deleteSelectedRows} keyText="Ctrl+Delete">
Delete selected rows
</DropDownMenuItem>
)}
{insertNewRow && (
<DropDownMenuItem onClick={insertNewRow} keyText="Insert">
Insert new row
</DropDownMenuItem>
)}
<DropDownMenuDivider />
<DropDownMenuItem onClick={setNull} keyText="Ctrl+0">
Set NULL
</DropDownMenuItem>
{setNull && (
<DropDownMenuItem onClick={setNull} keyText="Ctrl+0">
Set NULL
</DropDownMenuItem>
)}
{exportGrid && <DropDownMenuItem onClick={exportGrid}>Export</DropDownMenuItem>}
<DropDownMenuItem onClick={filterSelectedValue} keyText="Ctrl+F">
Filter selected value
</DropDownMenuItem>
{filterSelectedValue && (
<DropDownMenuItem onClick={filterSelectedValue} keyText="Ctrl+F">
Filter selected value
</DropDownMenuItem>
)}
{openQuery && <DropDownMenuItem onClick={openQuery}>Open query</DropDownMenuItem>}
<DropDownMenuItem onClick={openFreeTable}>Open selection in free table editor</DropDownMenuItem>
</>

View File

@ -345,13 +345,13 @@ export default function DataGridCore(props) {
event.pageY,
<DataGridContextMenu
copy={handleCopy}
revertRowChanges={revertRowChanges}
deleteSelectedRows={deleteSelectedRows}
insertNewRow={insertNewRow}
reload={() => display.reload()}
setNull={setNull}
revertRowChanges={grider.containsChanges ? revertRowChanges : null}
deleteSelectedRows={grider.editable ? deleteSelectedRows : null}
insertNewRow={grider.editable ? insertNewRow : null}
reload={display.supportsReload ? () => display.reload() : null}
setNull={grider.editable ? setNull : null}
exportGrid={exportGrid}
filterSelectedValue={filterSelectedValue}
filterSelectedValue={display.filterable ? filterSelectedValue : null}
openQuery={openQuery}
openFreeTable={handleOpenFreeTable}
/>