/* Licensed under the MIT License (MIT) Copyright (c) 2016 David Hara */ import * as React from 'react'; import Griddle, { ColumnMetaData, CustomHeaderComponentProps } from 'griddle-react'; interface MoreCustomHeaderComponentProps extends CustomHeaderComponentProps { color: string; } class HeaderComponent extends React.Component { textOnClick(e: React.FormEvent) { e.stopPropagation(); } filterText(e: React.FormEvent) { this.props.filterByColumn(e.currentTarget.value, this.props.columnName) } render() { return (
{this.props.displayName}
); } } interface ResultType { id: number; name: string; city: string; state: string; country: string; company: string; favoriteNumber: number; } var someData: ResultType[] = [ { "id": 0, "name": "Mayer Leonard", "city": "Kapowsin", "state": "Hawaii", "country": "United Kingdom", "company": "Ovolo", "favoriteNumber": 7 }, { "id": 1, "name": "Koch Becker", "city": "Johnsonburg", "state": "New Jersey", "country": "Madagascar", "company": "Eventage", "favoriteNumber": 2 } ]; var columnMeta: ColumnMetaData[] = [ { columnName: 'name', order: 1, sortable: false, visible: true, }, { columnName: 'city', customHeaderComponent: HeaderComponent, customHeaderComponentProps: {color: 'red'} }, { columnName: 'state', customHeaderComponent: HeaderComponent, customHeaderComponentProps: {color: 'blue'} } ]; class CustomHeaderComponentGrid extends React.Component { render() { type TypedGriddle = new () => Griddle; const TypedGriddle = Griddle as TypedGriddle; return ( ); } } export default CustomHeaderComponentGrid;