mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Update DataTableBindingManager.ts
This commit is contained in:
parent
aefa46c7f4
commit
54eb320965
@ -1,14 +1,15 @@
|
||||
import * as ko from "knockout";
|
||||
import * as _ from "underscore";
|
||||
|
||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
||||
import * as Constants from "../Constants";
|
||||
import * as Entities from "../Entities";
|
||||
import * as Utilities from "../Utilities";
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import * as DataTableBuilder from "./DataTableBuilder";
|
||||
import DataTableOperationManager from "./DataTableOperationManager";
|
||||
import QueryTablesTab from "../../Tabs/QueryTablesTab";
|
||||
import * as DataTableOperations from "./DataTableOperations";
|
||||
import TableEntityListViewModel from "./TableEntityListViewModel";
|
||||
import * as Utilities from "../Utilities";
|
||||
import * as Entities from "../Entities";
|
||||
|
||||
/**
|
||||
* Custom binding manager of datatable
|
||||
@ -41,10 +42,6 @@ function bindDataTable(element: any, valueAccessor: any, allBindings: any, viewM
|
||||
createDataTable(0, tableEntityListViewModel, queryTablesTab); // Fake a DataTable to start.
|
||||
$(window).resize(updateTableScrollableRegionMetrics);
|
||||
operationManager.focusTable(); // Also selects the first row if needed.
|
||||
// Attach the arrow key event handler to the table element
|
||||
$dataTable.on("keydown", (event: JQueryEventObject) => {
|
||||
handlearrowkey(element, valueAccessor, allBindings, viewModel, bindingContext, event);
|
||||
});
|
||||
}
|
||||
|
||||
function onTableColumnChange(enablePrompt: boolean = true, queryTablesTab: QueryTablesTab) {
|
||||
@ -213,39 +210,6 @@ function selectionChanged(element: any, valueAccessor: any, allBindings: any, vi
|
||||
});
|
||||
//selected = bindingContext.$data.selected();
|
||||
}
|
||||
function handlearrowkey(
|
||||
element: any,
|
||||
valueAccessor: any,
|
||||
allBindings: any,
|
||||
viewModel: any,
|
||||
bindingContext: any,
|
||||
event: JQueryEventObject
|
||||
) {
|
||||
let isUpArrowKey: boolean = event.keyCode === Constants.keyCodes.UpArrow;
|
||||
let isDownArrowKey: boolean = event.keyCode === Constants.keyCodes.DownArrow;
|
||||
|
||||
if (isUpArrowKey || isDownArrowKey) {
|
||||
let $dataTable = $(element);
|
||||
let $selectedRow = $dataTable.find("tr.selected");
|
||||
|
||||
if ($selectedRow.length === 0) {
|
||||
// No row is currently selected, select the first row
|
||||
$selectedRow = $dataTable.find("tr:first");
|
||||
$selectedRow.addClass("selected");
|
||||
} else {
|
||||
let $targetRow = isUpArrowKey ? $selectedRow.prev("tr") : $selectedRow.next("tr");
|
||||
|
||||
if ($targetRow.length > 0) {
|
||||
// Remove the selected class from the current row and add it to the target row
|
||||
$selectedRow.removeClass("selected").attr("tabindex", "-1");
|
||||
$targetRow.addClass("selected").attr("tabindex", "0");
|
||||
$targetRow.focus();
|
||||
}
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
function dataChanged(element: any, valueAccessor: any, allBindings: any, viewModel: any, bindingContext: any) {
|
||||
// do nothing for now
|
||||
|
Loading…
x
Reference in New Issue
Block a user