Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Generic Cotton Gloves
Electronics
503.84
2
Handmade Cotton Chair
Beauty
215.22
3
Sleek Silk Fish
Beauty
16.52
4
Fantastic Silk Cheese
Sports
431.84
5
Unbranded Concrete Soap
Sports
183.1
6
Handcrafted Wooden Ball
Sports
151.93
7
Incredible Rubber Table
Clothing
49.5
8
Tasty Plastic Pizza
Electronics
647.13
9
Handmade Rubber Salad
Clothing
237.22
10
Practical Wooden Sausages
Beauty
230.67
11
Fresh Granite Cheese
Beauty
212
12
Practical Granite Fish
Home & Garden
134.94
13
Soft Rubber Salad
Home & Garden
298.19
14
Small Concrete Shoes
Beauty
39.7
15
Incredible Aluminum Hat
Sports
337.58
16
Tasty Bamboo Ball
Clothing
113.53
17
Soft Bronze Shoes
Electronics
571.54
18
Ergonomic Cotton Mouse
Sports
70.32
19
Practical Bronze Pants
Clothing
452.15
20
Bespoke Silk Fish
Beauty
414.57
21
Ergonomic Concrete Hat
Clothing
402.95
22
Fantastic Bamboo Chicken
Clothing
492.65
23
Small Ceramic Gloves
Home & Garden
223.77
24
Awesome Marble Salad
Electronics
656.33
25
Modern Silk Cheese
Beauty
252.24
26
Unbranded Wooden Cheese
Electronics
1839.65
27
Soft Bronze Chair
Clothing
357.79
28
Practical Bamboo Bacon
Electronics
1086.2
29
Gorgeous Silk Computer
Beauty
246.78
30
Recycled Steel Car
Sports
259.7
31
Intelligent Rubber Sausages
Sports
312.27
32
Modern Silk Tuna
Sports
122.57
33
Small Silk Chicken
Electronics
566.53
34
Sleek Gold Soap
Beauty
226.39
35
Modern Concrete Shoes
Clothing
276.88
36
Incredible Concrete Soap
Beauty
172.73
37
Handmade Gold Table
Electronics
255.54
38
Intelligent Steel Chicken
Clothing
160.78
39
Frozen Aluminum Bacon
Clothing
165.49
40
Electronic Gold Towels
Electronics
1498.88
41
Tasty Aluminum Computer
Clothing
34.96
42
Electronic Plastic Soap
Beauty
414.88
43
Sleek Marble Gloves
Beauty
77.78
44
Generic Marble Table
Clothing
249.16
45
Handmade Bronze Hat
Clothing
474.13
46
Refined Wooden Keyboard
Electronics
1603.18
47
Ergonomic Granite Cheese
Sports
185.73
48
Practical Aluminum Shoes
Clothing
400.96
49
Tasty Aluminum Chicken
Electronics
329.61
50
Frozen Rubber Soap
Home & Garden
30.92

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.