Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Practical Plastic Soap
Clothing
255.41
2
Intelligent Gold Table
Home & Garden
250.12
3
Modern Rubber Cheese
Sports
236.6
4
Soft Marble Cheese
Home & Garden
443.87
5
Electronic Marble Hat
Beauty
413.91
6
Bespoke Bamboo Car
Electronics
1553.96
7
Refined Bronze Chicken
Sports
66.97
8
Handmade Metal Chips
Sports
219.03
9
Oriental Steel Bike
Clothing
229.53
10
Incredible Granite Shirt
Home & Garden
134.63
11
Incredible Rubber Chair
Sports
141.05
12
Licensed Silk Shoes
Sports
491.17
13
Luxurious Silk Towels
Sports
448.46
14
Small Plastic Pants
Home & Garden
472.57
15
Generic Cotton Soap
Sports
451.16
16
Practical Metal Bacon
Home & Garden
184.97
17
Refined Cotton Computer
Beauty
59.15
18
Oriental Bronze Pants
Beauty
417.95
19
Gorgeous Bronze Car
Beauty
252.36
20
Elegant Marble Salad
Home & Garden
204.72
21
Ergonomic Metal Shirt
Electronics
1976.65
22
Handcrafted Metal Hat
Beauty
270.13
23
Small Granite Tuna
Electronics
1689.65
24
Modern Wooden Table
Beauty
216.8
25
Handmade Concrete Table
Home & Garden
415.02
26
Oriental Marble Mouse
Beauty
464.47
27
Practical Cotton Salad
Beauty
102.56
28
Awesome Metal Bike
Home & Garden
20.06
29
Frozen Silk Pants
Sports
415.12
30
Generic Silk Sausages
Clothing
414.76
31
Generic Bamboo Gloves
Clothing
308.54
32
Fantastic Plastic Ball
Beauty
322.73
33
Tasty Ceramic Towels
Electronics
800.97
34
Electronic Granite Chicken
Home & Garden
324.44
35
Rustic Silk Pizza
Sports
436.93
36
Oriental Wooden Bike
Beauty
366.57
37
Bespoke Ceramic Soap
Beauty
336.15
38
Luxurious Silk Gloves
Sports
233.74
39
Tasty Ceramic Pizza
Home & Garden
437.59
40
Small Cotton Sausages
Beauty
329.42
41
Recycled Concrete Shirt
Clothing
180.93
42
Electronic Ceramic Pants
Sports
397.7
43
Unbranded Wooden Salad
Beauty
328.51
44
Ergonomic Gold Table
Electronics
338.13
45
Sleek Marble Salad
Clothing
392.07
46
Fresh Metal Table
Clothing
294.93
47
Awesome Steel Ball
Beauty
334.85
48
Oriental Bamboo Shirt
Sports
306.31
49
Intelligent Concrete Chicken
Home & Garden
370.05
50
Incredible Rubber Chicken
Clothing
412.62

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.