1. Features
  2. Row Selection

Features

Row Selection

Discover how to enable and configure row selection in your GridCraft data grid table. Empower users to interact with and manipulate data by selecting individual rows in your SvelteKit applications.


Name
Status
Age
Abraham Baker Abraham.Baker@gmail.com
Active
42
Adem Lane Adem.Lane@icloud.com
Active
73
Adil Floyd Adil.Floyd@icloud.com
Pending
72
Adriana O'Sullivan Adriana.OSullivan@protonmail.com
Inactive
26
Alec Whitten AW_41@yahoo.com
Active
67

Enabling Row Selection

To enable row selection in your GridCraft data grid table, follow these steps:

1
2

Full Example

<script>
import { Grid, type GridColumn } from "@mediakular/gridcraft";

interface Client {
    id: string;
    firstname: string;
    lastname: string;
    age: number;
}

export let data: PageData;
let clients: Client[] = data.clients;

let showCheckboxes = true;
let selectedRows:Client[] = [];

let columns: GridColumn<Client>[] = [
    { 
        key: 'firstname', 
        title: 'First Name',
    },
    { 
        key: 'lastname', 
        title: 'First Name',
    },
    { 
        key: 'age', 
        title: 'Age'
    },
];
</script>

<!-- Just for demonstration purposes -->
<label for="showCheckboxes">
    <input type="checkbox" checked={showCheckboxes == true} on:change={() => showCheckboxes = !showCheckboxes} id="showCheckboxes" />
    &nbsp;Show checkboxes
</label>
{#if showCheckboxes}
    Selected Rows:
    <pre>
        {JSON.stringify(selectedRows, null, 2)}
    </pre>
{/if}
<!-- End: Just for demonstration purposes -->

<Grid 
    bind:data={clients} 
    bind:columns
    bind:selectedRows
    bind:showCheckboxes />