UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

191 lines (190 loc) 6.33 kB
/** * DevExtreme (esm/__internal/grids/data_grid/module_widget_base.js) * Version: 22.1.9 * Build date: Tue Apr 18 2023 * * Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ import $ from "../../../core/renderer"; import registerComponent from "../../../core/component_registrator"; import { deferRender, noop } from "../../../core/utils/common"; import { isFunction, isString } from "../../../core/utils/type"; import { each } from "../../../core/utils/iterator"; import { extend } from "../../../core/utils/extend"; import { logger } from "../../../core/utils/console"; import browser from "../../../core/utils/browser"; import Widget from "../../../ui/widget/ui.widget"; import { isMaterial } from "../../../ui/themes"; import gridCore from "./module_core"; import "./module_not_extended/column_headers"; import "./module_columns_controller"; import "./module_data_controller"; import "./module_not_extended/sorting"; import "./module_not_extended/rows"; import "./module_not_extended/context_menu"; import "./module_not_extended/error_handling"; import "./module_not_extended/grid_view"; import "./module_not_extended/header_panel"; const DATAGRID_ROW_SELECTOR = ".dx-row"; const DATAGRID_DEPRECATED_TEMPLATE_WARNING = "Specifying grid templates with the jQuery selector name is now deprecated. Use the DOM Node or the jQuery object that references this selector instead."; gridCore.registerModulesOrder(["stateStoring", "columns", "selection", "editorFactory", "columnChooser", "grouping", "editing", "editingRowBased", "editingFormBased", "editingCellBased", "masterDetail", "validating", "adaptivity", "data", "virtualScrolling", "columnHeaders", "filterRow", "headerPanel", "headerFilter", "sorting", "search", "rows", "pager", "columnsResizingReordering", "contextMenu", "keyboardNavigation", "errorHandling", "summary", "columnFixing", "export", "gridView"]); const DataGrid = Widget.inherit({ _activeStateUnit: ".dx-row", _getDefaultOptions() { const result = this.callBase(); each(gridCore.modules, (function() { if (isFunction(this.defaultOptions)) { extend(true, result, this.defaultOptions()) } })); return result }, _setDeprecatedOptions() { this.callBase(); extend(this._deprecatedOptions, { useKeyboard: { since: "19.2", alias: "keyboardNavigation.enabled" }, rowTemplate: { since: "21.2", message: 'Use the "dataRowTemplate" option instead' } }) }, _defaultOptionsRules() { return this.callBase().concat([{ device: { platform: "ios" }, options: { showRowLines: true } }, { device: () => isMaterial(), options: { showRowLines: true, showColumnLines: false, headerFilter: { height: 315 }, editing: { useIcons: true }, selection: { showCheckBoxesMode: "always" } } }, { device: () => browser.webkit, options: { loadingTimeout: 30, loadPanel: { animation: { show: { easing: "cubic-bezier(1, 0, 1, 0)", duration: 500, from: { opacity: 0 }, to: { opacity: 1 } } } } } }, { device: device => "desktop" !== device.deviceType, options: { grouping: { expandMode: "rowClick" } } }]) }, _init() { this.callBase(); gridCore.processModules(this, gridCore); gridCore.callModuleItemsMethod(this, "init") }, _clean: noop, _optionChanged(args) { const that = this; gridCore.callModuleItemsMethod(that, "optionChanged", [args]); if (!args.handled) { that.callBase(args) } }, _dimensionChanged() { this.updateDimensions(true) }, _visibilityChanged(visible) { if (visible) { this.updateDimensions() } }, _initMarkup() { this.callBase.apply(this, arguments); this.getView("gridView").render(this.$element()) }, _renderContentImpl() { this.getView("gridView").update() }, _renderContent() { const that = this; deferRender(() => { that._renderContentImpl() }) }, _getTemplate(templateName) { let template = templateName; if (isString(template) && template.startsWith("#")) { template = $(templateName); logger.warn(DATAGRID_DEPRECATED_TEMPLATE_WARNING) } return this.callBase(template) }, _dispose() { this.callBase(); gridCore.callModuleItemsMethod(this, "dispose") }, isReady() { return this.getController("data").isReady() }, beginUpdate() { this.callBase(); gridCore.callModuleItemsMethod(this, "beginUpdate") }, endUpdate() { gridCore.callModuleItemsMethod(this, "endUpdate"); this.callBase() }, getController(name) { return this._controllers[name] }, getView(name) { return this._views[name] }, focus(element) { this.getController("keyboardNavigation").focus(element) } }); DataGrid.registerModule = gridCore.registerModule.bind(gridCore); registerComponent("dxDataGrid", DataGrid); export default DataGrid;