Skip to main content

Adding header and footer spans

To add headers and footers that span multiple columns, use the columns property. You need to specify the number of spanned columns as the value of the colspan parameter in the header or/and footer object.

<script>
import { Grid } from "@wx/svelte-grid";
import { getData } from "./common/data";

const { data } = getData();

const columns = [
{ id: "id", width: 50, footer: { text: "All users", colspan: 7 } },
{
id: "firstName",
header: [
{
text: "Main client info",
colspan: 5,
collapsible: true,
open: true,
},
{
text: "User",
colspan: 2,
collapsible: true,
open: true,
},
{ text: "First Name" },
],
width: 150,
},
{
id: "lastName",
header: ["", "", "Last Name"],
width: 150,
},
{
id: "companyName",
header: [
"",
{
text: "Company",
colspan: 2,
collapsible: true,
},
{ text: "Name" },
],
},
];
</script>

<div style="padding: 20px;">
<div>
<Grid {data} {columns} />
</div>
</div>

To add headers and footers that span multiple rows, you should specify the number of spanned rows as the value of the rowspan parameter in the header or/and footer object.

<script>
import { Grid } from "@wx/svelte-grid";

const { data } = getData();

const columns = [
{ id: "id", width: 50 },
{
id: "firstName",
header: [
{ text: "Main client info", colspan: 5 },
{ text: "User", colspan: 2 },
],
width: 150,
},
{
id: "lastName",
header: "Last Name",
footer: "Last Name",
width: 150,
options: [{ id: "1", name: "Ciara Towne" }],
},
{
id: "email",
header: ["", { text: "Email", rowspan: 2, css: "center" }],
},
{ id: "companyName", header: "Company", footer: "Company" },
{ id: "stars", header: "Stars", width: 150 },
];
</script>

<div style="padding: 20px;">
<div>
<Grid {data} {columns} />
</div>
</div>