Basic datagrid

Most basic headless implementation.

Example

Id
Name
Category
Price Retail
1
Electronic Concrete Cheese
Clothing
35.04
2
Small Steel Sausages
Beauty
419.74
3
Licensed Silk Table
Beauty
347.56
4
Tasty Marble Fish
Sports
432.39
5
Soft Concrete Pants
Home & Garden
107.54
6
Luxurious Ceramic Pizza
Home & Garden
229.65
7
Bespoke Aluminum Salad
Home & Garden
207.15
8
Handmade Wooden Hat
Sports
167.68
9
Modern Plastic Pants
Clothing
456.36
10
Modern Plastic Fish
Sports
45.59
11
Gorgeous Wooden Shirt
Home & Garden
257.86
12
Oriental Marble Ball
Clothing
379.96
13
Practical Metal Ball
Sports
164.82
14
Luxurious Bronze Towels
Sports
256.6
15
Modern Ceramic Computer
Sports
434.26
16
Intelligent Rubber Car
Sports
368.44
17
Electronic Bamboo Fish
Sports
107.27
18
Refined Granite Cheese
Electronics
240
19
Oriental Gold Soap
Sports
206.2
20
Soft Concrete Chips
Home & Garden
131.3
21
Intelligent Metal Hat
Beauty
53.07
22
Practical Metal Car
Electronics
1584.66
23
Unbranded Aluminum Chips
Sports
306.01
24
Fresh Bamboo Chicken
Sports
139.19
25
Soft Gold Salad
Clothing
265.19
26
Generic Bronze Shoes
Home & Garden
88.22
27
Oriental Cotton Fish
Electronics
1208.94
28
Ergonomic Silk Gloves
Beauty
127.14
29
Recycled Concrete Salad
Electronics
886.53
30
Awesome Bronze Sausages
Home & Garden
439.08
31
Gorgeous Granite Chair
Sports
257.54
32
Bespoke Cotton Chair
Clothing
259.4
33
Handcrafted Ceramic Sausages
Home & Garden
24.42
34
Soft Ceramic Bike
Beauty
473.7
35
Handcrafted Gold Chicken
Sports
207.24
36
Elegant Cotton Soap
Home & Garden
456.23
37
Intelligent Aluminum Pizza
Electronics
1465.13
38
Soft Cotton Bacon
Beauty
398.98
39
Unbranded Bronze Soap
Electronics
764.54
40
Intelligent Metal Table
Clothing
398.4
41
Modern Plastic Ball
Home & Garden
266.63
42
Oriental Concrete Chair
Electronics
439.76
43
Frozen Steel Sausages
Electronics
1130.51
44
Luxurious Wooden Chair
Sports
345.71
45
Refined Cotton Sausages
Electronics
779.56
46
Unbranded Granite Ball
Home & Garden
49.4
47
Modern Metal Chair
Clothing
284.6
48
Oriental Concrete Chair
Electronics
962.72
49
Ergonomic Rubber Bike
Clothing
135.92
50
Frozen Bronze Pizza
Clothing
405.21

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.