data-table
Una tabla de cifras en una tarjeta. En una pantalla estrecha, desplaza la tarjeta en horizontal para ver todas las columnas. Los encabezados de fila siguen a la vista.
Ordenada por un número
<div rst-box-head >
<h2 id ="sales-h" >Ventas por semana</h2 >
</div >
<div rst-card rst-table-scroll ="" tabindex ="0" role ="region" aria-labelledby ="sales-h" >
<table rst-table ="" aria-labelledby ="sales-h" >
<thead >
<tr >
<th scope ="col" >Semana</th >
<th scope ="col" rst-num aria-sort ="descending" >
<a href ="/sales?sort=sold&dir=asc" >Vendidas<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="m6 9 6 6 6-6" /></svg ></a >
</th >
<th scope ="col" rst-num >
<a href ="/sales?sort=target&dir=desc" >Objetivo<svg class ="icon" viewBox ="0 0 24 24" fill ="none" stroke ="currentColor" stroke-width ="2" stroke-linecap ="round" stroke-linejoin ="round" aria-hidden ="true" ><path d ="m6 9 6 6 6-6" /></svg ></a >
</th >
<th scope ="col" rst-num >Reembolsos</th >
</tr >
</thead >
<tbody >
<tr >
<th scope ="row" >3</th >
<td rst-num >260</td >
<td rst-num >600</td >
<td rst-num >5</td >
</tr >
<tr >
<th scope ="row" >4</th >
<td rst-num >240</td >
<td rst-num >600</td >
<td rst-num >1</td >
</tr >
<tr >
<th scope ="row" >2</th >
<td rst-num >180</td >
<td rst-num >600</td >
<td rst-num >0</td >
</tr >
<tr >
<th scope ="row" >1</th >
<td rst-num >120</td >
<td rst-num >600</td >
<td rst-num >2</td >
</tr >
</tbody >
<tfoot >
<tr >
<th scope ="row" >Total</th >
<td rst-num >800</td >
<td rst-num >2400</td >
<td rst-num >8</td >
</tr >
</tfoot >
</table >
</div >
{{ template "data-table" dict
"Columns" (list
(dict "Label" "Semana" )
(dict "Href" "/sales?sort=sold&dir=asc" "Label" "Vendidas" "Num" true "Sort" "descending" )
(dict "Href" "/sales?sort=target&dir=desc" "Label" "Objetivo" "Num" true )
(dict "Label" "Reembolsos" "Num" true ))
"Foot" (list "Total" 800 2400 8)
"ID" "sales"
"Rows" (list (list 3 260 600 5) (list 4 240 600 1) (list 2 180 600 0) (list 1 120 600 2))
"Title" "Ventas por semana" }}
Enlaza el encabezado de una columna a la lista ordenada y luego pon Sort en esa columna. Marca las columnas de números con Num.
Densa, con el encabezado fijo
<div rst-box-head >
<h2 id ="sales-dense-h" >Ventas por semana</h2 >
</div >
<div rst-card rst-table-scroll ="bounded" tabindex ="0" role ="region" aria-labelledby ="sales-dense-h" >
<table rst-table ="dense" aria-labelledby ="sales-dense-h" >
<thead >
<tr >
<th scope ="col" >Semana</th >
<th scope ="col" rst-num >Vendidas</th >
<th scope ="col" rst-num >Objetivo</th >
<th scope ="col" rst-num >Reembolsos</th >
</tr >
</thead >
<tbody >
<tr >
<th scope ="row" >1</th >
<td rst-num >120</td >
<td rst-num >600</td >
<td rst-num >2</td >
</tr >
<tr >
<th scope ="row" >2</th >
<td rst-num >180</td >
<td rst-num >600</td >
<td rst-num >0</td >
</tr >
<tr >
<th scope ="row" >3</th >
<td rst-num >260</td >
<td rst-num >600</td >
<td rst-num >5</td >
</tr >
<tr >
<th scope ="row" >4</th >
<td rst-num >240</td >
<td rst-num >600</td >
<td rst-num >1</td >
</tr >
<tr >
<th scope ="row" >5</th >
<td rst-num >390</td >
<td rst-num >600</td >
<td rst-num >3</td >
</tr >
<tr >
<th scope ="row" >6</th >
<td rst-num >610</td >
<td rst-num >600</td >
<td rst-num >4</td >
</tr >
<tr >
<th scope ="row" >7</th >
<td rst-num >650</td >
<td rst-num >600</td >
<td rst-num >0</td >
</tr >
<tr >
<th scope ="row" >8</th >
<td rst-num >690</td >
<td rst-num >600</td >
<td rst-num >2</td >
</tr >
</tbody >
</table >
</div >
{{ template "data-table" dict
"Bounded" true
"Columns" (list
(dict "Label" "Semana" )
(dict "Label" "Vendidas" "Num" true )
(dict "Label" "Objetivo" "Num" true )
(dict "Label" "Reembolsos" "Num" true ))
"Dense" true
"ID" "sales-dense"
"Rows" (list (list 1 120 600 2) (list 2 180 600 0) (list 3 260 600 5) (list 4 240 600 1) (list 5 390 600 3) (list 6 610 600 4) (list 7 650 600 0) (list 8 690 600 2))
"Title" "Ventas por semana" }}
Dense ajusta las filas. Bounded limita la altura y mantiene el encabezado a la vista mientras se desplazan las filas.
Ninguna fila coincide
<div rst-box-head >
<h2 id ="sales-none-h" >Ventas por semana</h2 >
</div >
<div rst-card rst-table-scroll ="" tabindex ="0" role ="region" aria-labelledby ="sales-none-h" >
<table rst-table ="" aria-labelledby ="sales-none-h" >
<thead >
<tr >
<th scope ="col" >Semana</th >
<th scope ="col" rst-num >Vendidas</th >
<th scope ="col" rst-num >Objetivo</th >
<th scope ="col" rst-num >Reembolsos</th >
</tr >
</thead >
<tbody >
<tr rst-table-empty >
<td colspan ="4" >Ninguna semana coincide.</td >
</tr >
</tbody >
</table >
</div >
{{ template "data-table" dict
"Columns" (list
(dict "Label" "Semana" )
(dict "Label" "Vendidas" "Num" true )
(dict "Label" "Objetivo" "Num" true )
(dict "Label" "Reembolsos" "Num" true ))
"Empty" "Ninguna semana coincide."
"ID" "sales-none"
"Title" "Ventas por semana" }}
Sin filas, el encabezado se queda y Empty explica por qué.