Getting Started with Tzezar's Datagrid
Welcome to the quick start guide for Tzezar’s Datagrid Core! This guide will help you rapidly implement the headless version of the datagrid in your project.
Quick Overview
Tzezar’s Datagrid Core provides a flexible, headless implementation that lets you build powerful data tables without being constrained by specific UI frameworks. This guide covers:
- Setting up your data
- Defining columns
- Creating a datagrid instance
- Rendering your datagrid
Let’s get started!
1. Setting Up Your Data
Every datagrid needs data to display. Here’s a simple example:
2. Defining Columns
Columns define how your data is structured and displayed:
Column Types Explained
accessorColumn
: Displays data directly from your objectscomputedColumn
: Combines or transforms data from multiple fieldsdisplayColumn
: Shows custom content not tied to your datacolumnGroup
: Organizes columns into logical groups
Tip: Add
satisfies ColumnDef<InventoryItem>[]
to get TypeScript IntelliSense support.
3. Creating a Datagrid Instance
Now that you have data and columns, create your datagrid:
Customizing Your Datagrid
For basic needs, this configuration is sufficient. For more control, you can:
- Set an initial state:
- Extend built-in features:
4. Rendering Your Datagrid
Since this is a headless library, you have complete freedom over rendering. Here’s a basic implementation using <div>
elements:
Using Custom Cell Rendering
For more complex cell content, you can use Svelte 5 snippets:
or prebuilt component:
Built-in <RenderCell />
component makes rendering custom cell content straightforward.
Why Use <div>
Instead of <table>
?
While traditional HTML tables work for simple cases, <div>
-based structures offer significant advantages:
- Better styling flexibility with CSS Grid and Flexbox
- Improved performance for large datasets through virtual scrolling
- Custom scroll behavior for features like sticky headers
- More control over column resizing and reordering
- Better integration with modern JavaScript frameworks
Next Steps
Congratulations on setting up your first Tzezar’s Datagrid! From here, you can:
- Explore the API reference for detailed documentation
- Check out examples for common patterns and advanced usage.
- Try the Enhanced Datagrid if you need a ready-made component with built-in UI and some abstraction layer
Advanced Features
Tzezar’s Datagrid Core comes with powerful features you can tap into:
Ready to build powerful, flexible data grids? Dive deeper into the documentation or check out the examples to see what Tzezar’s Datagrid can do for your project!