MCPcopy
hub / github.com/TanStack/table / App

Function App

examples/solid/column-visibility/src/App.tsx:98–216  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96]
97
98function App() {
99 const [data, setData] = createSignal(defaultData)
100 const [columnVisibility, setColumnVisibility] = createSignal<VisibilityState>(
101 {}
102 )
103 const rerender = () => setData(defaultData)
104
105 const table = createSolidTable({
106 get data() {
107 return data()
108 },
109 columns: defaultColumns,
110 state: {
111 get columnVisibility() {
112 return columnVisibility()
113 },
114 },
115 onColumnVisibilityChange: setColumnVisibility,
116 getCoreRowModel: getCoreRowModel(),
117 })
118
119 return (
120 <div class="p-2">
121 <div class="inline-block border border-black shadow rounded">
122 <div class="px-1 border-b border-black">
123 <label>
124 <input
125 checked={table.getIsAllColumnsVisible()}
126 onChange={table.getToggleAllColumnsVisibilityHandler()}
127 type="checkbox"
128 />{' '}
129 Toggle All
130 </label>
131 </div>
132 <For each={table.getAllLeafColumns()}>
133 {column => (
134 <div class="px-1">
135 <label>
136 <input
137 checked={column.getIsVisible()}
138 onChange={column.getToggleVisibilityHandler()}
139 type="checkbox"
140 />{' '}
141 {column.id}
142 </label>
143 </div>
144 )}
145 </For>
146 </div>
147 <div class="h-4" />
148 <table>
149 <thead>
150 <For each={table.getHeaderGroups()}>
151 {headerGroup => (
152 <tr>
153 <For each={headerGroup.headers}>
154 {header => (
155 <th colSpan={header.colSpan}>

Callers

nothing calls this directly

Calls 5

createSolidTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getContextMethod · 0.80
rerenderFunction · 0.70

Tested by

no test coverage detected