igniteui-cli 15.1.0 → 15.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/PromptSession.d.ts +1 -1
- package/lib/PromptSession.js +2 -2
- package/lib/commands/ai-config.d.ts +3 -5
- package/lib/commands/ai-config.js +68 -23
- package/lib/commands/new.js +1 -1
- package/package.json +4 -4
- package/templates/blazor/igb/index.d.ts +1 -0
- package/templates/blazor/igb/index.js +12 -0
- package/templates/blazor/igb/projects/ai-config/files/AGENTS.md +65 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/AGENTS.md +65 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/README.md +61 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/SKILL.md +118 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/charts.md +302 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/data-display.md +350 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/feedback.md +178 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/form-controls.md +365 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/layout-manager.md +180 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/layout.md +322 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/mcp-setup.md +78 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/setup.md +214 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-generate-from-image-design/SKILL.md +284 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-generate-from-image-design/references/component-mapping.md +281 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-generate-from-image-design/references/gotchas.md +503 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/SKILL.md +188 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/data-operations.md +264 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/editing.md +297 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/features.md +447 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/mcp-setup.md +78 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/paging-remote.md +299 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/sizing.md +284 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/state.md +160 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/structure.md +497 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/types.md +553 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-theming/SKILL.md +259 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-theming/references/common-patterns.md +276 -0
- package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-theming/references/mcp-setup.md +81 -0
- package/templates/blazor/igb/projects/ai-config/index.d.ts +22 -0
- package/templates/blazor/igb/projects/ai-config/index.js +62 -0
- package/templates/blazor/index.d.ts +3 -0
- package/templates/blazor/index.js +11 -0
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Paging, Remote Data & Virtualization
|
|
2
|
+
|
|
3
|
+
> **Part of the [`igniteui-blazor-grids`](../SKILL.md) skill hub.**
|
|
4
|
+
> For grid setup and column configuration — see [`structure.md`](./structure.md).
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- [Paging with `IgbPaginator`](#paging-with-igbpaginator)
|
|
9
|
+
- [Remote Paging](#remote-paging)
|
|
10
|
+
- [Remote Data Operations](#remote-data-operations)
|
|
11
|
+
- [Virtualization](#virtualization)
|
|
12
|
+
- [Key Rules](#key-rules)
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Paging with `IgbPaginator`
|
|
17
|
+
|
|
18
|
+
The grid does not have built-in paging. Instead, place an `IgbPaginator` component inside the grid:
|
|
19
|
+
|
|
20
|
+
### Basic paging
|
|
21
|
+
|
|
22
|
+
```razor
|
|
23
|
+
<IgbGrid Data="data" PrimaryKey="Id" AutoGenerate="false"
|
|
24
|
+
Width="100%" Height="500px">
|
|
25
|
+
<IgbColumn Field="Id" Header="ID" />
|
|
26
|
+
<IgbColumn Field="Name" Header="Name" />
|
|
27
|
+
<IgbColumn Field="Department" Header="Department" />
|
|
28
|
+
<IgbPaginator PerPage="10" />
|
|
29
|
+
</IgbGrid>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Paginator parameters
|
|
33
|
+
|
|
34
|
+
| Parameter | Type | Default | Description |
|
|
35
|
+
|---|---|---|---|
|
|
36
|
+
| `PerPage` | `int` | `15` | Rows per page |
|
|
37
|
+
| `TotalRecords` | `int` | - | Total record count (required for remote paging) |
|
|
38
|
+
| `SelectOptions` | `int[]` | `[5, 10, 15, 25, 50]` | Page size dropdown options |
|
|
39
|
+
|
|
40
|
+
### Paginator events
|
|
41
|
+
|
|
42
|
+
| Event | Type | Description |
|
|
43
|
+
|---|---|---|
|
|
44
|
+
| `PerPageChanged` | `EventCallback<int>` | Fires when page size changes |
|
|
45
|
+
| `PageChanged` | `EventCallback<int>` | Fires when current page changes |
|
|
46
|
+
| `PagingDone` | `EventCallback<IgbPagingEventArgs>` | Fires after paging completes |
|
|
47
|
+
|
|
48
|
+
### Programmatic paging
|
|
49
|
+
|
|
50
|
+
```razor
|
|
51
|
+
<IgbGrid @ref="grid" Data="data" PrimaryKey="Id">
|
|
52
|
+
<IgbPaginator @ref="paginator" PerPage="10" />
|
|
53
|
+
...
|
|
54
|
+
</IgbGrid>
|
|
55
|
+
|
|
56
|
+
<IgbButton @onclick="GoToFirstPage">First Page</IgbButton>
|
|
57
|
+
<IgbButton @onclick="GoToNextPage">Next Page</IgbButton>
|
|
58
|
+
|
|
59
|
+
@code {
|
|
60
|
+
private IgbGrid grid = default!;
|
|
61
|
+
private IgbPaginator paginator = default!;
|
|
62
|
+
|
|
63
|
+
private async Task GoToFirstPage()
|
|
64
|
+
{
|
|
65
|
+
await paginator.PaginateAsync(0);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private async Task GoToNextPage()
|
|
69
|
+
{
|
|
70
|
+
await paginator.NextPageAsync();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Paginator navigation methods
|
|
76
|
+
|
|
77
|
+
| Method | Description |
|
|
78
|
+
|---|---|
|
|
79
|
+
| `PaginateAsync(int page)` | Go to a specific page (0-based index) |
|
|
80
|
+
| `NextPageAsync()` | Go to the next page |
|
|
81
|
+
| `PreviousPageAsync()` | Go to the previous page |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Remote Paging
|
|
86
|
+
|
|
87
|
+
When data lives on a server, fetch only the current page:
|
|
88
|
+
|
|
89
|
+
```razor
|
|
90
|
+
<IgbGrid @ref="grid" Data="currentPageData" PrimaryKey="Id"
|
|
91
|
+
AutoGenerate="false" Width="100%" Height="500px">
|
|
92
|
+
<IgbColumn Field="Id" Header="ID" />
|
|
93
|
+
<IgbColumn Field="Name" Header="Name" />
|
|
94
|
+
<IgbColumn Field="Department" Header="Department" />
|
|
95
|
+
<IgbPaginator PerPage="@pageSize"
|
|
96
|
+
TotalRecords="@totalRecords"
|
|
97
|
+
PageChanged="OnPageChanged"
|
|
98
|
+
PerPageChanged="OnPerPageChanged" />
|
|
99
|
+
</IgbGrid>
|
|
100
|
+
|
|
101
|
+
@code {
|
|
102
|
+
private IgbGrid grid = default!;
|
|
103
|
+
private List<Employee> currentPageData = new();
|
|
104
|
+
private int totalRecords = 0;
|
|
105
|
+
private int pageSize = 20;
|
|
106
|
+
private int currentPage = 0;
|
|
107
|
+
|
|
108
|
+
protected override async Task OnInitializedAsync()
|
|
109
|
+
{
|
|
110
|
+
await LoadPageAsync();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private async Task OnPageChanged(int page)
|
|
114
|
+
{
|
|
115
|
+
currentPage = page;
|
|
116
|
+
await LoadPageAsync();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async Task OnPerPageChanged(int newPageSize)
|
|
120
|
+
{
|
|
121
|
+
pageSize = newPageSize;
|
|
122
|
+
currentPage = 0;
|
|
123
|
+
await LoadPageAsync();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private async Task LoadPageAsync()
|
|
127
|
+
{
|
|
128
|
+
var result = await Api.GetEmployeesPagedAsync(currentPage, pageSize);
|
|
129
|
+
currentPageData = result.Items;
|
|
130
|
+
totalRecords = result.TotalCount;
|
|
131
|
+
StateHasChanged();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Key points for remote paging
|
|
137
|
+
|
|
138
|
+
1. **Set `TotalRecords`** on the paginator - this tells it the total number of records on the server.
|
|
139
|
+
2. **Bind `Data` to the current page** - only the current page's data is in memory.
|
|
140
|
+
3. **Handle `PageChanged` and `PerPageChanged`** - fetch new data from the server on each event.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Remote Data Operations
|
|
145
|
+
|
|
146
|
+
For large datasets, disable client-side sorting/filtering and handle them on the server.
|
|
147
|
+
|
|
148
|
+
### Remote sorting
|
|
149
|
+
|
|
150
|
+
```razor
|
|
151
|
+
<IgbGrid @ref="grid" Data="data" PrimaryKey="Id"
|
|
152
|
+
SortingDone="OnSortingDone">
|
|
153
|
+
<IgbColumn Field="Name" Sortable="true" />
|
|
154
|
+
<IgbColumn Field="Department" Sortable="true" />
|
|
155
|
+
<IgbColumn Field="Salary" Sortable="true" DataType="GridColumnDataType.Number" />
|
|
156
|
+
<IgbPaginator PerPage="@pageSize" TotalRecords="@totalRecords"
|
|
157
|
+
PageChanged="OnPageChanged" />
|
|
158
|
+
</IgbGrid>
|
|
159
|
+
|
|
160
|
+
@code {
|
|
161
|
+
private IgbGrid grid = default!;
|
|
162
|
+
private List<Employee> data = new();
|
|
163
|
+
private int totalRecords = 0;
|
|
164
|
+
private int pageSize = 20;
|
|
165
|
+
private int currentPage = 0;
|
|
166
|
+
private IgbSortingExpression[]? currentSort;
|
|
167
|
+
|
|
168
|
+
private async Task OnSortingDone(IgbSortingEventArgs args)
|
|
169
|
+
{
|
|
170
|
+
currentSort = args.SortingExpressions;
|
|
171
|
+
currentPage = 0;
|
|
172
|
+
await LoadDataAsync();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private async Task OnPageChanged(int page)
|
|
176
|
+
{
|
|
177
|
+
currentPage = page;
|
|
178
|
+
await LoadDataAsync();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
private async Task LoadDataAsync()
|
|
182
|
+
{
|
|
183
|
+
var result = await Api.GetEmployeesAsync(
|
|
184
|
+
page: currentPage,
|
|
185
|
+
pageSize: pageSize,
|
|
186
|
+
sortField: currentSort?.FirstOrDefault()?.FieldName,
|
|
187
|
+
sortDir: currentSort?.FirstOrDefault()?.Dir.ToString()
|
|
188
|
+
);
|
|
189
|
+
data = result.Items;
|
|
190
|
+
totalRecords = result.TotalCount;
|
|
191
|
+
StateHasChanged();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Remote filtering
|
|
197
|
+
|
|
198
|
+
```razor
|
|
199
|
+
<IgbGrid @ref="grid" Data="data" PrimaryKey="Id"
|
|
200
|
+
AllowFiltering="true"
|
|
201
|
+
FilteringDone="OnFilteringDone">
|
|
202
|
+
<IgbColumn Field="Name" Filterable="true" DataType="GridColumnDataType.String" />
|
|
203
|
+
<IgbColumn Field="Department" Filterable="true" DataType="GridColumnDataType.String" />
|
|
204
|
+
</IgbGrid>
|
|
205
|
+
|
|
206
|
+
@code {
|
|
207
|
+
private IgbGrid grid = default!;
|
|
208
|
+
private List<Employee> data = new();
|
|
209
|
+
|
|
210
|
+
private async Task OnFilteringDone(IgbFilteringEventArgs args)
|
|
211
|
+
{
|
|
212
|
+
// Extract filter information and send to server
|
|
213
|
+
var filterExpressions = args.FilteringExpressions;
|
|
214
|
+
var result = await Api.GetEmployeesFilteredAsync(filterExpressions);
|
|
215
|
+
data = result.Items;
|
|
216
|
+
StateHasChanged();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Combined remote operations pattern
|
|
222
|
+
|
|
223
|
+
For production apps, combine paging, sorting, and filtering into a single server call:
|
|
224
|
+
|
|
225
|
+
```razor
|
|
226
|
+
@code {
|
|
227
|
+
private int currentPage = 0;
|
|
228
|
+
private int pageSize = 20;
|
|
229
|
+
private int totalRecords = 0;
|
|
230
|
+
private IgbSortingExpression[]? currentSort;
|
|
231
|
+
private string? filterField;
|
|
232
|
+
private string? filterValue;
|
|
233
|
+
|
|
234
|
+
private async Task LoadDataAsync()
|
|
235
|
+
{
|
|
236
|
+
var result = await Api.QueryAsync(new QueryRequest
|
|
237
|
+
{
|
|
238
|
+
Page = currentPage,
|
|
239
|
+
PageSize = pageSize,
|
|
240
|
+
SortField = currentSort?.FirstOrDefault()?.FieldName,
|
|
241
|
+
SortDirection = currentSort?.FirstOrDefault()?.Dir.ToString(),
|
|
242
|
+
FilterField = filterField,
|
|
243
|
+
FilterValue = filterValue
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
data = result.Items;
|
|
247
|
+
totalRecords = result.TotalCount;
|
|
248
|
+
StateHasChanged();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## Virtualization
|
|
256
|
+
|
|
257
|
+
### How virtualization works
|
|
258
|
+
|
|
259
|
+
Virtualization is **built-in and automatic**. The grid only renders DOM elements for the visible viewport. As the user scrolls, rows and cells are recycled.
|
|
260
|
+
|
|
261
|
+
### Requirements
|
|
262
|
+
|
|
263
|
+
1. **The grid must have a fixed `Height`** - set `Height="500px"` or `Height="80vh"`. Without a height, the grid renders all rows and virtualization is disabled.
|
|
264
|
+
2. **Column widths help column virtualization** - when total column width exceeds the grid width, columns outside the viewport are not rendered.
|
|
265
|
+
|
|
266
|
+
### Row virtualization
|
|
267
|
+
|
|
268
|
+
```razor
|
|
269
|
+
<IgbGrid Data="largeDataSet" PrimaryKey="Id"
|
|
270
|
+
Width="100%" Height="600px" AutoGenerate="true" />
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Even with 100,000+ rows, only ~20-30 (depending on row height and grid height) are rendered at any time.
|
|
274
|
+
|
|
275
|
+
### Column virtualization
|
|
276
|
+
|
|
277
|
+
```razor
|
|
278
|
+
<IgbGrid Data="wideData" PrimaryKey="Id" Width="800px" Height="600px">
|
|
279
|
+
@for (int i = 0; i < 50; i++)
|
|
280
|
+
{
|
|
281
|
+
<IgbColumn Field="@($"Col{i}")" Header="@($"Column {i}")" Width="150px" />
|
|
282
|
+
}
|
|
283
|
+
</IgbGrid>
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
With 50 columns at 150px each (7500px total) in an 800px wide grid, only the visible columns are rendered.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Key Rules
|
|
291
|
+
|
|
292
|
+
1. **`IgbPaginator` goes inside the grid** - it is a child component, not a sibling.
|
|
293
|
+
2. **Remote paging requires `TotalRecords`** - without it, the paginator cannot calculate page count.
|
|
294
|
+
3. **Handle events for remote operations** - `SortingDone`, `FilteringDone`, `PageChanged` are your hooks to fetch server data.
|
|
295
|
+
4. **Virtualization needs a fixed `Height`** - this is the #1 performance requirement.
|
|
296
|
+
5. **Do not use `.Skip().Take()` on `IQueryable` directly on the grid** - the grid expects a materialized collection (`List<T>` or `T[]`). Fetch data asynchronously and set it as the `Data` property.
|
|
297
|
+
6. **`StateHasChanged()` after data updates** - call it after reassigning the `Data` property from an async operation.
|
|
298
|
+
7. **Remote operations override client-side** - when using remote sorting/filtering, the grid still shows sort/filter UI, but you handle the actual data transformation on the server.
|
|
299
|
+
8. **Paging is not available on IgbPivotGrid** - the Pivot Grid does not support pagination.
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
# Sizing - Grid Width, Height, Column Sizing & Cell Spacing
|
|
2
|
+
|
|
3
|
+
> **Part of the [`igniteui-blazor-grids`](../SKILL.md) skill hub.**
|
|
4
|
+
> For grid setup and column configuration — see [`structure.md`](./structure.md).
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- [Grid Width](#grid-width)
|
|
9
|
+
- [Grid Height](#grid-height)
|
|
10
|
+
- [Column Sizing](#column-sizing)
|
|
11
|
+
- [Row Height](#row-height)
|
|
12
|
+
- [Cell Spacing (CSS Variables)](#cell-spacing-css-variables)
|
|
13
|
+
- [Key Rules](#key-rules)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Grid Width
|
|
18
|
+
|
|
19
|
+
### Pixel width
|
|
20
|
+
|
|
21
|
+
```razor
|
|
22
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="800px" Height="500px">
|
|
23
|
+
...
|
|
24
|
+
</IgbGrid>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Percentage width
|
|
28
|
+
|
|
29
|
+
```razor
|
|
30
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="100%" Height="500px">
|
|
31
|
+
...
|
|
32
|
+
</IgbGrid>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Default width
|
|
36
|
+
|
|
37
|
+
When `Width` is not set, the grid defaults to `100%` of its parent container.
|
|
38
|
+
|
|
39
|
+
### Key behavior
|
|
40
|
+
|
|
41
|
+
- If the total column width exceeds the grid width, a horizontal scrollbar appears and column virtualization activates.
|
|
42
|
+
- If the total column width is less than the grid width, columns stretch to fill (unless explicit widths are set).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Grid Height
|
|
47
|
+
|
|
48
|
+
### Pixel height
|
|
49
|
+
|
|
50
|
+
```razor
|
|
51
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="100%" Height="600px">
|
|
52
|
+
...
|
|
53
|
+
</IgbGrid>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Percentage height
|
|
57
|
+
|
|
58
|
+
```razor
|
|
59
|
+
<!-- Parent must have a defined height for percentage to work -->
|
|
60
|
+
<div style="height: 80vh;">
|
|
61
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="100%" Height="100%">
|
|
62
|
+
...
|
|
63
|
+
</IgbGrid>
|
|
64
|
+
</div>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### No height (null/unset)
|
|
68
|
+
|
|
69
|
+
When `Height` is not set, the grid renders **all rows** without a vertical scrollbar. This disables row virtualization.
|
|
70
|
+
|
|
71
|
+
```razor
|
|
72
|
+
<!-- No Height: renders all rows, no virtualization -->
|
|
73
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="100%">
|
|
74
|
+
...
|
|
75
|
+
</IgbGrid>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
> **Warning:** Without a height, large datasets will render all rows to the DOM, causing severe performance degradation. Always set `Height` for datasets with more than 50 rows.
|
|
79
|
+
|
|
80
|
+
### Auto height
|
|
81
|
+
|
|
82
|
+
The grid does not have a built-in "auto height" mode. To fit a limited number of rows, calculate the height:
|
|
83
|
+
|
|
84
|
+
```razor
|
|
85
|
+
@{
|
|
86
|
+
var rowCount = Math.Min(data.Count, 20);
|
|
87
|
+
var gridHeight = $"{50 + rowCount * 50}px"; // 50px header + 50px per row
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
<IgbGrid Data="data" PrimaryKey="Id" Width="100%" Height="@gridHeight">
|
|
91
|
+
...
|
|
92
|
+
</IgbGrid>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Column Sizing
|
|
98
|
+
|
|
99
|
+
### Fixed pixel width
|
|
100
|
+
|
|
101
|
+
```razor
|
|
102
|
+
<IgbColumn Field="Id" Header="ID" Width="80px" />
|
|
103
|
+
<IgbColumn Field="Name" Header="Name" Width="250px" />
|
|
104
|
+
<IgbColumn Field="Department" Header="Department" Width="200px" />
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Percentage width
|
|
108
|
+
|
|
109
|
+
```razor
|
|
110
|
+
<IgbColumn Field="Id" Header="ID" Width="10%" />
|
|
111
|
+
<IgbColumn Field="Name" Header="Name" Width="40%" />
|
|
112
|
+
<IgbColumn Field="Department" Header="Department" Width="25%" />
|
|
113
|
+
<IgbColumn Field="Salary" Header="Salary" Width="25%" />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Auto-size (fit content)
|
|
117
|
+
|
|
118
|
+
No explicit width - the column auto-sizes:
|
|
119
|
+
|
|
120
|
+
```razor
|
|
121
|
+
<IgbColumn Field="Name" Header="Name" />
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Without a `Width`, the grid distributes available space proportionally among columns.
|
|
125
|
+
|
|
126
|
+
### Min/Max width constraints
|
|
127
|
+
|
|
128
|
+
```razor
|
|
129
|
+
<IgbColumn Field="Name" Header="Name" Width="200px" MinWidth="100px" MaxWidth="400px" Resizable="true" />
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
- `MinWidth` prevents the column from shrinking below a threshold (useful with resizing).
|
|
133
|
+
- `MaxWidth` prevents the column from growing beyond a threshold.
|
|
134
|
+
|
|
135
|
+
### Column resizing
|
|
136
|
+
|
|
137
|
+
```razor
|
|
138
|
+
<IgbGrid Data="data" PrimaryKey="Id">
|
|
139
|
+
<IgbColumn Field="Name" Header="Name" Width="200px" Resizable="true" />
|
|
140
|
+
<IgbColumn Field="Department" Header="Department" Width="200px" Resizable="true" />
|
|
141
|
+
<IgbColumn Field="Salary" Header="Salary" Width="150px" Resizable="true" />
|
|
142
|
+
</IgbGrid>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Users can drag column borders to resize. Combine with `MinWidth` and `MaxWidth` for constrained resizing.
|
|
146
|
+
|
|
147
|
+
### Auto-size column to fit content
|
|
148
|
+
|
|
149
|
+
Programmatically auto-size a column to fit its longest cell value:
|
|
150
|
+
|
|
151
|
+
```razor
|
|
152
|
+
@code {
|
|
153
|
+
private IgbGrid grid = default!;
|
|
154
|
+
|
|
155
|
+
private async Task AutoSizeNameColumn()
|
|
156
|
+
{
|
|
157
|
+
var column = grid.GetColumnByName("Name");
|
|
158
|
+
await grid.AutoSizeColumnWidthAsync(column);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private async Task AutoSizeAllColumns()
|
|
162
|
+
{
|
|
163
|
+
await grid.AutoSizeColumnsWidthAsync();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Column auto-width on init
|
|
169
|
+
|
|
170
|
+
```razor
|
|
171
|
+
<IgbColumn Field="Name" Header="Name" AutoSize="true" />
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
When `AutoSize="true"`, the column width adjusts on initial render to fit the header and visible content.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Row Height
|
|
179
|
+
|
|
180
|
+
### Default row height
|
|
181
|
+
|
|
182
|
+
The default row height depends on the theme's display density. Use `DisplayDensity` on the grid:
|
|
183
|
+
|
|
184
|
+
```razor
|
|
185
|
+
<IgbGrid Data="data" PrimaryKey="Id" DisplayDensity="DisplayDensity.Comfortable">
|
|
186
|
+
...
|
|
187
|
+
</IgbGrid>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Display Density | Approximate Row Height |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `Comfortable` | 50px (default) |
|
|
193
|
+
| `Cosy` | 40px |
|
|
194
|
+
| `Compact` | 32px |
|
|
195
|
+
|
|
196
|
+
### Custom row height
|
|
197
|
+
|
|
198
|
+
Use CSS to override row height:
|
|
199
|
+
|
|
200
|
+
```css
|
|
201
|
+
igc-grid::part(tbody-content) igc-grid-row {
|
|
202
|
+
height: 60px;
|
|
203
|
+
}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Or use `RowHeight` parameter:
|
|
207
|
+
|
|
208
|
+
```razor
|
|
209
|
+
<IgbGrid Data="data" PrimaryKey="Id" RowHeight="60">
|
|
210
|
+
...
|
|
211
|
+
</IgbGrid>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Cell Spacing (CSS Variables)
|
|
217
|
+
|
|
218
|
+
Control cell padding and spacing using CSS custom properties:
|
|
219
|
+
|
|
220
|
+
```css
|
|
221
|
+
igc-grid {
|
|
222
|
+
--ig-grid-cell-padding-block: 12px; /* top and bottom padding */
|
|
223
|
+
--ig-grid-cell-padding-inline: 16px; /* left and right padding */
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Available CSS variables for grid spacing
|
|
228
|
+
|
|
229
|
+
| CSS Variable | Description | Default |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| `--ig-grid-cell-padding-block` | Vertical cell padding | Theme-dependent |
|
|
232
|
+
| `--ig-grid-cell-padding-inline` | Horizontal cell padding | Theme-dependent |
|
|
233
|
+
| `--ig-size` | Overall component size (affects row height, cell padding) | `var(--ig-size-large)` |
|
|
234
|
+
|
|
235
|
+
### Sizing via `--ig-size`
|
|
236
|
+
|
|
237
|
+
The grid respects the global `--ig-size` CSS variable for responsive sizing:
|
|
238
|
+
|
|
239
|
+
```css
|
|
240
|
+
/* Compact grid */
|
|
241
|
+
igc-grid {
|
|
242
|
+
--ig-size: var(--ig-size-small);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/* Medium grid */
|
|
246
|
+
igc-grid {
|
|
247
|
+
--ig-size: var(--ig-size-medium);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Large grid (default) */
|
|
251
|
+
igc-grid {
|
|
252
|
+
--ig-size: var(--ig-size-large);
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Scoped sizing
|
|
257
|
+
|
|
258
|
+
Apply different sizing to a specific grid:
|
|
259
|
+
|
|
260
|
+
```razor
|
|
261
|
+
<IgbGrid Data="data" PrimaryKey="Id" class="compact-grid">
|
|
262
|
+
...
|
|
263
|
+
</IgbGrid>
|
|
264
|
+
|
|
265
|
+
<style>
|
|
266
|
+
.compact-grid {
|
|
267
|
+
--ig-size: var(--ig-size-small);
|
|
268
|
+
}
|
|
269
|
+
</style>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Key Rules
|
|
275
|
+
|
|
276
|
+
1. **Always set `Height` for performance** - without it, virtualization is disabled and all rows render to the DOM.
|
|
277
|
+
2. **Percentage height needs a sized parent** - `Height="100%"` only works if the parent element has an explicit height.
|
|
278
|
+
3. **Box model is border-box** - column widths include padding and borders.
|
|
279
|
+
4. **Horizontal scroll triggers when columns overflow** - if total column width > grid width, a horizontal scrollbar appears.
|
|
280
|
+
5. **`MinWidth` and `MaxWidth` constrain resizing** - always set them when `Resizable="true"` for predictable UX.
|
|
281
|
+
6. **`--ig-size` controls the overall density** - it affects row height, cell padding, header height, and internal spacing.
|
|
282
|
+
7. **Column virtualization requires column widths** - without widths, the grid cannot calculate which columns are outside the viewport.
|
|
283
|
+
8. **Auto-size is a one-time operation** - `AutoSize="true"` on a column fits content at initial render; it doesn't update dynamically as data changes.
|
|
284
|
+
9. **Row height consistency** - all rows in a grid have the same height. Variable row height is not supported.
|