@@ -3,6 +3,7 @@ import TableLoader, { filterType } from "qwik-table-loader"
33import { CellData , FilterValue } from "qwik-table-loader/lib-types/types"
44
55export default component$ ( ( ) => {
6+ // You can have a set of options for your filter
67 const statusOptions : FilterValue [ ] = [
78 {
89 key : 0 ,
@@ -22,6 +23,7 @@ export default component$(() => {
2223 } ,
2324 ]
2425
26+ // Given this is your raw data
2527 const data = [
2628 {
2729 id : 1 ,
@@ -60,6 +62,7 @@ export default component$(() => {
6062 } ,
6163 ]
6264
65+ // Special data types (eg. Date) should be optimized before loading to the table
6366 const tData = data . map ( ( record : any ) => {
6467 return {
6568 ...record ,
@@ -73,6 +76,7 @@ export default component$(() => {
7376 }
7477 } )
7578
79+ // Custom format table cell "dob"
7680 const formatDob = $ ( ( record : CellData , heading : string ) => {
7781 const list = record [ heading ] ?. toString ( ) ?. split ( "-" )
7882 if ( list ) {
@@ -81,6 +85,7 @@ export default component$(() => {
8185 return ""
8286 } )
8387
88+ // Custom format table cell "status"
8489 const formatStatus = $ ( ( record : CellData , heading : string ) => {
8590 switch ( record [ heading ] ) {
8691 case 0 :
@@ -118,26 +123,29 @@ export default component$(() => {
118123
119124 return (
120125 < >
121- < Link href = "/" >
122- < span class = "text-blue-500 underline" > << Go Back</ span >
123- </ Link >
124126 < TableLoader
127+ // Your optimized data.
125128 tData = { tData }
129+ // Your custom elements based on the column types
126130 element = { {
127131 dob : formatDob ,
128132 status : formatStatus ,
129133 } }
130134 tableOptions = { {
135+ // Customize your heading text here...
131136 customHeadings : {
132137 dob : "Date of Birth" ,
133138 } ,
139+ // For pure CSS, you can attach class names and add .css file styling those classes
140+ // For TailwindCSS, this is where you customize your table styling
134141 classNames : {
135142 table : "my-6 mx-3 border-2 border-[#333]" ,
136143 thead : "bg-gray-600 border-2 border-[#333]" ,
137144 th : "text-white border border-[#333] p-2 px-4" ,
138145 thContent : "h-full flex flex-col gap-1 min-w-[30px]" ,
139146 thText :
140147 "min-h-[24px] flex flex-row items-center justify-between gap-2" ,
148+ // Arrows' size, default color and highlight color should be store like this format in sortContainer
141149 sortContainer :
142150 "flex flex-col -mr-1 size-[20] default-[#ccc] highlight-[#fff]" ,
143151 sortArrowUp : "-mb-[7px]" ,
@@ -148,22 +156,27 @@ export default component$(() => {
148156 tbody : "bg-gray-100" ,
149157 tr : "border border-[#ccc]" ,
150158 td : "border border-[#ccc] p-1 px-3" ,
159+ // Custom class names based on column name
151160 tcol : {
152161 id : "max-w-[80px] text-center" ,
153162 fullName : "font-bold" ,
154163 dob : "max-w-[160px] text-right" ,
155164 } ,
156165 } ,
166+ // Sort options: choose which columns to have the sort feature included
157167 sortOptions : {
158168 params : [ "username" , "fullName" , "dob" , "status" ] ,
159169 } ,
160170 filterOptions : {
171+ // You can use the filterType enum, or simply type "search" or "options"
161172 params : {
162173 username : filterType . SEARCH ,
163174 fullName : filterType . SEARCH ,
164175 dob : filterType . SEARCH ,
165176 status : filterType . OPTIONS ,
166177 } ,
178+ // If a column has "options" filter, it needs to have an option list
179+ // Otherwise, the options will be blank
167180 options : {
168181 status : statusOptions ,
169182 } ,
0 commit comments