UNPKG

@progress/kendo-react-grid

Version:
88 lines 3.99 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); var utils_1 = require("./../utils"); var kendo_react_inputs_1 = require("@progress/kendo-react-inputs"); var kendo_react_dateinputs_1 = require("@progress/kendo-react-dateinputs"); var kendo_react_common_1 = require("@progress/kendo-react-common"); /** * @hidden */ var GridEditCell = /** @class */ (function (_super) { __extends(GridEditCell, _super); function GridEditCell() { var _this = _super !== null && _super.apply(this, arguments) || this; _this._inputId = kendo_react_common_1.guid(); /** * @hidden */ _this.handleOnChange = function (syntheticEvent) { if (_this.props.onChange) { var value = syntheticEvent.target.type === 'checkbox' ? syntheticEvent.target.checked : syntheticEvent.target.value; _this.props.onChange({ dataItem: _this.props.dataItem, field: _this.props.field, syntheticEvent: syntheticEvent, value: value }); } }; /** * @hidden */ _this.inputChange = function (e) { if (_this.props.onChange) { _this.props.onChange({ dataItem: _this.props.dataItem, field: _this.props.field, syntheticEvent: e.syntheticEvent, value: e.value }); } }; return _this; } /** * @hidden */ GridEditCell.prototype.render = function () { var data = utils_1.getNestedValue(this.props.field, this.props.dataItem); var defaultRendering = null; switch (this.props.editor) { case 'numeric': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement(kendo_react_inputs_1.NumericTextBox, { width: "100%", value: (data === undefined) ? null : data, onChange: this.inputChange }))); break; case 'date': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement(kendo_react_dateinputs_1.DatePicker, { width: "100%", value: data, onChange: this.inputChange }))); break; case 'boolean': defaultRendering = (React.createElement("td", { className: this.props.className }, React.createElement("input", { checked: data || false, id: this._inputId, type: "checkbox", className: "k-checkbox", onChange: this.handleOnChange }), React.createElement("label", { className: "k-checkbox-label", htmlFor: this._inputId }))); break; default: defaultRendering = (React.createElement("td", { className: this.props.className, style: this.props.style }, React.createElement("input", { style: { width: '100%' }, className: "k-textbox", value: data || '', onChange: this.handleOnChange }))); } return this.props.render ? this.props.render.call(undefined, defaultRendering, this.props) : defaultRendering; }; return GridEditCell; }(React.Component)); exports.GridEditCell = GridEditCell; //# sourceMappingURL=GridEditCell.js.map