ag-grid-enterprise
Version:
ag-Grid Enterprise Features
37 lines (28 loc) • 1.29 kB
text/typescript
import {Autowired, Component, Context, GridOptionsWrapper, PostConstruct, RefSelector} from 'ag-grid-community';
export class NameValueComp extends Component {
private gridOptionsWrapper: GridOptionsWrapper;
private context: Context;
private static TEMPLATE = `<div class="ag-name-value">
<span ref="eLabel"></span>: <span ref="eValue" class="ag-name-value-value"></span>
</div>`;
private props: { key: string, defaultValue: string };
private eLabel: HTMLElement;
private eValue: HTMLElement;
constructor(private key: string, private defaultValue: string) {
super(NameValueComp.TEMPLATE);
}
protected postConstruct(): void {
if (this.props) {
this.key = this.props.key;
this.defaultValue = this.props.defaultValue;
}
// we want to hide until the first value comes in
this.setVisible(false);
let localeTextFunc = this.gridOptionsWrapper.getLocaleTextFunc();
this.eLabel.innerHTML = localeTextFunc(this.key, this.defaultValue);
}
public setValue(value: any): void {
this.eValue.innerHTML = value;
}
}