mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
parent
88322b5110
commit
b793e5180a
1 changed files with 17 additions and 1 deletions
|
|
@ -269,10 +269,26 @@ export class Home extends React.Component<RouteComponentProps<{}>, IHomeState> {
|
|||
|
||||
private renderColumnVisibilityCheckbox(props: IColumnVisibility) {
|
||||
return <div className="form-check form-check-inline">
|
||||
<input className="form-check-input" type="checkbox" id={`checkbox${props.column.replace(/\s+/g, "")}`} defaultChecked={props.visible} />
|
||||
<input className="form-check-input" type="checkbox"id={`checkbox${props.column.replace(/\s+/g, "")}`} defaultChecked={props.visible} onChange={() => this.checkColumn(props)}/>
|
||||
<label className="form-check-label" htmlFor={`checkbox${props.column.replace(/\s+/g, "")}`}>{props.column}</label>
|
||||
</div>;
|
||||
}
|
||||
|
||||
private checkColumn(props: IColumnVisibility) {
|
||||
const columnVisibility = this.state.columnVisibility;
|
||||
const index = this.findWithAttr(columnVisibility, "column", props.column);
|
||||
columnVisibility[index].visible = !columnVisibility[index].visible;
|
||||
this.forceUpdate();
|
||||
}
|
||||
|
||||
private findWithAttr(array: any, attr: any, value: any) {
|
||||
for (let i = 0; i < array.length; i += 1) {
|
||||
if (array[i][attr] === value) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
interface ISoftwareDto {
|
||||
|
|
|
|||
Loading…
Reference in a new issue