diff --git a/_contentTemplates/grid/state.md b/_contentTemplates/grid/state.md index 5c64aefa3c..9eaaadb693 100644 --- a/_contentTemplates/grid/state.md +++ b/_contentTemplates/grid/state.md @@ -716,14 +716,17 @@ + Reorderable="true" + Resizable="true"> Reorder Price and Quantity - Make Id Column Last + Resize Columns - Reset Column Order + Reset Column Configuration @@ -784,13 +787,32 @@ } } - private async Task ResetColumnOrder() + private async Task ResizeColumns() + { + if (GridRef != null) + { + var gridState = GridRef.GetState(); + int newColumnWidth = 160; + + foreach (GridColumnState columnState in gridState.ColumnStates) + { + columnState.Width = $"{newColumnWidth}px"; + } + + gridState.TableWidth = $"{newColumnWidth * gridState.ColumnStates.Count}px"; + + await GridRef.SetStateAsync(gridState); + } + } + + private async Task ResetColumns() { if (GridRef != null) { var gridState = GridRef.GetState(); gridState.ColumnStates = new List(); + gridState.TableWidth = null; await GridRef.SetStateAsync(gridState); } diff --git a/components/grid/state.md b/components/grid/state.md index 049bc989f1..fb6c7f7b6d 100644 --- a/components/grid/state.md +++ b/components/grid/state.md @@ -43,7 +43,7 @@ The Grid state is a generic [class `GridState`](slug:Telerik.Blazor.Compo | `SelectedItems` | `ICollection` | The currently [selected data item(s)](slug:grid-selection-overview). | | `Skip` | `int?` | The number of scrolled data items when using [virtual row scrolling](slug:components/grid/virtual-scrolling). In other words, this is the number of rows above the currently visible ones. | | `SortDescriptors` | `ICollection` | The currently applied [sorts](slug:components/grid/features/sorting). | -| `TableWidth` | `string` | The sum of all visible column widths. This property changes together with `ColumnStates`. The `OnStateChanged` event does not fire separately for it. | +| `TableWidth` | `string` | The sum of all visible column widths. The initial value is always `null` regardless of the column configuration. The `TableWidth` value changes during column resizing together with `ColumnStates` and the`OnStateChanged` event does not fire separately for it. When you resize a column programmatically, and all other columns already have widths, you must update the `TableWidth` too, otherwise the other columns will resize unexpectedly. | \* `TItem` is the Grid model type. diff --git a/components/treelist/state.md b/components/treelist/state.md index 4c16a7bb6e..30b0aa8272 100644 --- a/components/treelist/state.md +++ b/components/treelist/state.md @@ -42,7 +42,7 @@ The TreeList state is a generic [class `TreeListState`](slug:Telerik.Blaz | `SelectedItems` | `ICollection` | The currently [selected data item(s)](slug:treelist-selection-overview). | | `Skip` | `int?` | The number of scrolled data items when using [virtual row scrolling](slug:treelist-virtual-scrolling). In other words, this is the number of rows above the currently visible ones. | | `SortDescriptors` | `ICollection` | The currently applied [sorts](slug:treelist-sorting). | -| `TableWidth` | `string` | The sum of all visible column widths. This property changes together with `ColumnStates`. The `OnStateChanged` event does not fire separately for it. | +| `TableWidth` | `string` | The sum of all visible column widths. The initial value is always `null` regardless of the column configuration. The `TableWidth` value changes during column resizing together with `ColumnStates` and the`OnStateChanged` event does not fire separately for it. When you resize a column programmatically, and all other columns already have widths, you must update the `TableWidth` too, otherwise the other columns will resize unexpectedly. | \* `TItem` is the TreeList model type.