@progress/kendo-react-grid
Version:
KendoReact Grid package
87 lines • 2.97 kB
JavaScript
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 __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
import * as React from 'react';
/**
* @example
* ```jsx
* class App extends React.PureComponent {
* state = {
* details: false,
* data: [
* { foo: 'A1', bar: 'B1', b1: 1, b2:2 },
* { foo: 'A2', bar: 'B2', b1: 3, b2:4 },
* { foo: 'A3', bar: 'B2', b1: 5, b2:6 }
* ]
* };
*
* CustomHeaderCell = (props) =>
* <span>
* {props.title || props.field + ' '}
* <button onClick={() => this.setState({ barDetails: !this.state.barDetails })}>
* {this.state.barDetails ? 'collapse' : 'expand'}
* </button>
* </span>
*
* render() {
* return (
* <Grid
* style={{ height: '420px' }}
* data={this.state.data}
* reorderable={true}
* >
* <GridColumn field="foo" />
* <GridColumn field="bar" headerCell={this.CustomHeaderCell}>
* {this.state.barDetails && [
* <GridColumn field="b1" />,
* <GridColumn field="b2" />
* ]}
* </GridColumn>
* </Grid>
* );
* }
* }
*
* ReactDOM.render(<App />, document.querySelector('my-app'));
* ```
*/
var GridHeaderCell = /** @class */ (function (_super) {
__extends(GridHeaderCell, _super);
function GridHeaderCell(props) {
return _super.call(this, props) || this;
}
/**
* @hidden
*/
GridHeaderCell.prototype.render = function () {
var clickProps = this.props.onClick ? {
href: '#',
onClick: this.props.onClick
} : {};
var defaultRendering = (React.createElement("a", __assign({ className: "k-link" }, clickProps),
this.props.title || this.props.field || '\u00A0',
this.props.children));
if (this.props.render) {
return this.props.render.call(undefined, defaultRendering, this.props);
}
return defaultRendering;
};
return GridHeaderCell;
}(React.Component));
export { GridHeaderCell };
//# sourceMappingURL=GridHeaderCell.js.map