Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Luxurious Bamboo Tuna
Clothing
266.92
2
Fantastic Bronze Table
Sports
124.8
3
Handcrafted Concrete Cheese
Home & Garden
480.58
4
Ergonomic Steel Cheese
Clothing
127.56
5
Sleek Concrete Hat
Sports
77.61
6
Modern Gold Salad
Home & Garden
321.32
7
Gorgeous Aluminum Cheese
Clothing
41.82
8
Handmade Plastic Shirt
Sports
487.32
9
Ergonomic Wooden Keyboard
Sports
485.29
10
Frozen Bamboo Soap
Electronics
165.47
11
Modern Gold Car
Beauty
38.59
12
Fresh Granite Tuna
Beauty
39.8
13
Sleek Marble Gloves
Home & Garden
437.72
14
Sleek Granite Table
Beauty
117.18
15
Incredible Gold Bacon
Electronics
1595.73
16
Bespoke Gold Soap
Electronics
1918.79
17
Fresh Gold Car
Home & Garden
163.19
18
Rustic Cotton Gloves
Sports
33.81
19
Fantastic Metal Shoes
Beauty
146.86
20
Incredible Bronze Chips
Clothing
479.11
21
Generic Gold Salad
Beauty
422.6
22
Bespoke Bamboo Shirt
Clothing
167.28
23
Sleek Granite Fish
Clothing
59.31
24
Electronic Rubber Hat
Beauty
422.07
25
Refined Rubber Shoes
Beauty
336.16
26
Intelligent Bamboo Salad
Clothing
192.3
27
Licensed Metal Gloves
Home & Garden
314.98
28
Awesome Granite Pizza
Beauty
481.09
29
Gorgeous Wooden Chicken
Clothing
364.08
30
Tasty Aluminum Ball
Clothing
50.81
31
Sleek Marble Table
Electronics
1250.65
32
Sleek Cotton Mouse
Home & Garden
457.82
33
Luxurious Rubber Shoes
Sports
257.09
34
Electronic Metal Fish
Clothing
34.28
35
Fantastic Concrete Tuna
Sports
60.85
36
Intelligent Cotton Chips
Sports
277.84
37
Fresh Cotton Keyboard
Clothing
376.51
38
Practical Silk Soap
Sports
187.78
39
Fresh Metal Pants
Electronics
380.82
40
Intelligent Cotton Computer
Sports
126.76
41
Awesome Steel Table
Clothing
388.88
42
Luxurious Metal Keyboard
Electronics
1308.57
43
Elegant Aluminum Chicken
Clothing
106.39
44
Luxurious Wooden Bacon
Home & Garden
364.39
45
Fresh Cotton Towels
Beauty
98.64
46
Modern Cotton Bacon
Home & Garden
354.53
47
Incredible Ceramic Keyboard
Home & Garden
270.2
48
Intelligent Aluminum Fish
Home & Garden
198.58
49
Frozen Bamboo Cheese
Clothing
323.63
50
Frozen Metal Bike
Electronics
903.83

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.