Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Oriental Silk Bacon
Home & Garden
351.72
2
Gorgeous Gold Fish
Home & Garden
70
3
Ergonomic Plastic Cheese
Sports
25.47
4
Oriental Bronze Shirt
Electronics
659.57
5
Fresh Ceramic Sausages
Electronics
1430.55
6
Soft Steel Mouse
Sports
221.6
7
Ergonomic Steel Mouse
Sports
299.3
8
Modern Ceramic Table
Home & Garden
274.36
9
Sleek Concrete Car
Clothing
124.56
10
Refined Plastic Towels
Electronics
1695.04
11
Incredible Wooden Gloves
Electronics
1014.38
12
Handmade Concrete Hat
Beauty
456.37
13
Bespoke Granite Computer
Clothing
211.92
14
Handcrafted Aluminum Towels
Electronics
1447.97
15
Frozen Wooden Bacon
Home & Garden
56.68
16
Bespoke Cotton Pizza
Sports
191.31
17
Practical Concrete Shoes
Beauty
212.74
18
Oriental Metal Salad
Sports
21.39
19
Elegant Steel Ball
Home & Garden
166.33
20
Fresh Gold Hat
Clothing
276.24
21
Bespoke Aluminum Salad
Sports
72.36
22
Fantastic Ceramic Cheese
Sports
340.51
23
Awesome Cotton Pants
Sports
50.67
24
Bespoke Rubber Bike
Sports
348.38
25
Fantastic Granite Hat
Electronics
881.81
26
Soft Marble Tuna
Electronics
1274.35
27
Electronic Granite Chips
Sports
141.72
28
Ergonomic Bamboo Fish
Beauty
271.11
29
Intelligent Wooden Soap
Electronics
1903.76
30
Elegant Steel Bacon
Beauty
380.98
31
Generic Silk Hat
Beauty
394.59
32
Gorgeous Plastic Hat
Home & Garden
303.63
33
Practical Cotton Ball
Sports
301.62
34
Electronic Gold Ball
Sports
418.12
35
Frozen Ceramic Keyboard
Home & Garden
39.15
36
Oriental Metal Hat
Clothing
156.82
37
Awesome Ceramic Mouse
Home & Garden
64.01
38
Fresh Cotton Towels
Clothing
406.72
39
Refined Silk Bacon
Sports
50.91
40
Soft Bronze Chicken
Sports
471.38
41
Small Granite Chips
Clothing
98.05
42
Bespoke Gold Salad
Electronics
1712.74
43
Elegant Rubber Sausages
Sports
169.43
44
Elegant Steel Salad
Sports
418.69
45
Unbranded Ceramic Keyboard
Sports
495.45
46
Handmade Bamboo Chicken
Electronics
1741.22
47
Awesome Wooden Salad
Sports
395.81
48
Refined Gold Car
Clothing
184.22
49
Unbranded Bamboo Towels
Home & Garden
26.09
50
Soft Ceramic Chicken
Sports
476.55

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.