Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Generic Concrete Pizza
Sports
463.16
2
Sleek Granite Computer
Sports
286.58
3
Gorgeous Steel Chicken
Sports
14.94
4
Modern Ceramic Cheese
Clothing
358.83
5
Tasty Concrete Ball
Home & Garden
57.13
6
Practical Cotton Chicken
Clothing
345.04
7
Intelligent Bronze Mouse
Electronics
910.28
8
Soft Cotton Chicken
Beauty
450.26
9
Tasty Wooden Salad
Beauty
214.6
10
Ergonomic Steel Keyboard
Beauty
141.71
11
Unbranded Rubber Shirt
Clothing
44.46
12
Refined Steel Car
Electronics
305.75
13
Awesome Bamboo Bike
Clothing
471.25
14
Luxurious Granite Shoes
Sports
280.1
15
Electronic Marble Gloves
Beauty
353.28
16
Ergonomic Bamboo Bike
Home & Garden
165.86
17
Small Wooden Keyboard
Home & Garden
15.78
18
Electronic Rubber Soap
Electronics
1759.67
19
Fantastic Bronze Hat
Sports
251.59
20
Intelligent Bamboo Table
Beauty
349.49
21
Elegant Plastic Soap
Home & Garden
235.74
22
Bespoke Wooden Car
Home & Garden
225.91
23
Ergonomic Bronze Computer
Home & Garden
406.45
24
Bespoke Plastic Soap
Electronics
799.8
25
Handmade Wooden Pants
Beauty
129.27
26
Fantastic Plastic Chicken
Clothing
371.94
27
Awesome Ceramic Shirt
Clothing
28.75
28
Tasty Rubber Fish
Home & Garden
91.67
29
Fresh Cotton Salad
Home & Garden
308.6
30
Frozen Concrete Pizza
Electronics
1559.79
31
Recycled Rubber Chips
Electronics
1566.09
32
Ergonomic Rubber Bike
Beauty
304.54
33
Handcrafted Cotton Chicken
Clothing
427.61
34
Handmade Granite Salad
Electronics
456.23
35
Elegant Aluminum Shoes
Clothing
241.37
36
Elegant Concrete Shirt
Home & Garden
155.85
37
Fresh Granite Computer
Sports
272.22
38
Bespoke Wooden Ball
Beauty
489.74
39
Sleek Marble Chips
Home & Garden
147.53
40
Sleek Plastic Chips
Electronics
1879.02
41
Frozen Aluminum Towels
Beauty
114
42
Fresh Bamboo Keyboard
Home & Garden
146.99
43
Awesome Marble Chicken
Clothing
249.66
44
Bespoke Wooden Fish
Electronics
752.19
45
Elegant Rubber Gloves
Beauty
93.61
46
Recycled Cotton Ball
Sports
300.35
47
Licensed Bronze Keyboard
Beauty
285.73
48
Awesome Wooden Hat
Electronics
1618.88
49
Recycled Steel Gloves
Sports
221.06
50
Elegant Ceramic Soap
Clothing
375.23

Key Points

  1. State Management:

    DatagridCore is responsible for maintaining the entire state of the datagrid, including columns, rows, sorting, filtering, selection, and pagination.

  2. Mandatory Columns:

    The columns configuration is required for the datagrid to function properly.

  3. Retrieving Leaf Columns: `

    datagrid.columns.getLeafColumns()` is used to extract the lowest-level columns in a hierarchical column structure, ensuring correct TypeScript typings and preventing runtime errors.

  4. Processing Rows Safely:

    We iterate over the rows obtained from datagrid.rows.getVisibleBasicRows(), which ensures that only visible rows are processed while satisfying TypeScript constraints.

  5. Cell Rendering Logic:

    The getCellContent(column, row.original) function determines the correct content to render for each cell by mapping the given column to its corresponding data in the row.

  6. Performance Considerations:

    The system is optimized to handle large datasets efficiently by working with only the necessary subset of data at any given time.

  7. Extensibility:

    The architecture allows for additional features such as custom cell rendering, row virtualization, and advanced filtering without disrupting core functionality.

  8. Styling Flexibility:

    The structure is designed to be flexible in terms of styling. It is up to the user to decide how to style and render the datagrid. The following example demonstrates a possible approach using @apply with Tailwind CSS to create a structure similar to a traditional table, but users are free to apply their own styles and layout as needed.