UNPKG

igniteui-react-grids

Version:

Ignite UI React grid components.

85 lines (84 loc) 2.81 kB
import * as React from 'react'; import { NamePatcher, isValidProp, getModifiedProps } from "igniteui-react-core"; import { ReactRenderer } from "igniteui-react-core"; import { DataGridStylingDefaults } from './DataGridStylingDefaults'; import { GridColumnHideOptions } from './GridColumnHideOptions'; import { IgrGridColumnOptionsSimpleSectionBase } from "./igr-grid-column-options-simple-section-base"; export class IgrGridColumnHideOptions extends IgrGridColumnOptionsSimpleSectionBase { _getMainRef(ref) { this._elRef = ref; } render() { let children = []; React.Children.forEach(this.props.children, (ch) => { children.push(ch); }); let div = React.createElement("div", { className: "ig-grid-column-hide-options igr-grid-column-hide-options", ref: this._getMainRef, children: children }); return div; } constructor(props) { super(props); this._reactRenderer = null; if (this._styling) { NamePatcher.ensureStylablePatched(Object.getPrototypeOf(this)); } this._getMainRef = this._getMainRef.bind(this); if (document) { this._mainDiv = document.createElement("div"); this._mainDiv.style.display = "block"; this._mainDiv.style.width = "100%"; this._mainDiv.style.height = "100%"; } var ren = new ReactRenderer(this._mainDiv, document, true, DataGridStylingDefaults); this._reactRenderer = ren; var gridColumnHideOptions = this.i; gridColumnHideOptions.provideRenderer(ren); if (props) { this.initializeProperties(); } } shouldComponentUpdate(nextProps, nextState) { const mod = getModifiedProps(this.props, nextProps); for (const p of Object.keys(mod)) { if (isValidProp(this, p)) { this[p] = mod[p]; } } return true; } initializeProperties() { for (const p of Object.keys(this.props)) { if (isValidProp(this, p)) { this[p] = this.props[p]; } } } // supports angular themes or custom properties set in CSS updateStyle() { this._styling(this._mainDiv, this); } destroy() { this.i.destroy(); this._reactRenderer.destroy(); } componentWillUnmount() { } componentDidMount() { this._elRef.appendChild(this._mainDiv); this.initializeContent(); } initializeContent() { this._styling(this._mainDiv, this); this.updateStyle(); } createImplementation() { return new GridColumnHideOptions(); } get i() { return this._implementation; } }