You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/grid/columns/resize.md
+59-14Lines changed: 59 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,26 +10,59 @@ position: 3
10
10
11
11
# Resize Columns
12
12
13
-
The Grid lets the user resize its columns by dragging the borders between their headers.
13
+
The Grid features two different column resizing mechanisms:
14
14
15
-
To enable the column resizing, set the `Resizable` parameter of the grid to `true`.
15
+
*[Resize by Dragging](#resize-by-dragging)
16
+
*[Fit to Content](#autofit-columns)
17
+
18
+
The [example at the end of this page](#example) shows both options in action.
19
+
20
+
## Resize by Dragging
21
+
22
+
The Grid allows users to resize columns by dragging the borders between header cells.
23
+
24
+
To enable such column resizing, set the `Resizable` parameter of the grid to `true`.
16
25
17
26
To prevent the user from resizing a certain column, set its own parameter `Resizable="false"`. Note that the user can still resize other columns around it.
18
27
19
-
When column resizing is enabled, a double click on the resize handle between the header cells will automatically fit the column width to the content of the header, data and footers.
28
+
## Autofit Columns
29
+
30
+
When column resizing is enabled, a double click on the resize handle between the header cells will automatically fit the column width to the content of the header, data and footers. This will remove text wrapping in the component.
31
+
32
+
The Grid also exposes methods to programmatically resize columns to fit their contents:
33
+
34
+
*`AutoFitColumn(string id)` - autofits the column with the specified [`Id` attribute]({% slug components/grid/columns/bound%}#identification);
35
+
*`AutoFitColumns(IEnumerable<string> ids)` - autofits multiple columns at once'
36
+
*`AutoFitAllColumns()` - autofits all applicable columns (for example, this method does not affect the hierarchy expand/collapse columns);
20
37
21
-
>caption Enable column resizing in Telerik Grid
38
+
Autofitting specific columns preserves the current widths of all the other columns. Similar to [column resizing](#resize-by-dragging), column autofitting can trigger a horizontal Grid scrollbar, or leave empty space after the last column.
39
+
40
+
Programmatic autofitting works even if column resizing is disabled.
41
+
42
+
## Example
43
+
44
+
>caption How Column Resizing Works in the Telerik Grid
45
+
46
+

47
+
48
+
>caption Grid Column Resizing and Autofitting
22
49
23
50
````CSHTML
24
-
@* Drag the border between column headers to change the column size. You cannot resize the command column. Note that actual CRUD operations and settings are not implemented here for brevity. *@
51
+
@* Grid column resizing and autofitting *@
52
+
@* Drag the border between column headers to change the column width. The command column is not resizable by the user. *@
53
+
54
+
<TelerikButton OnClick="@AutoFitSingleColumn">AutoFit ID Column</TelerikButton>
Copy file name to clipboardExpand all lines: components/grid/columns/width.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ With regard to the widths of its columns, the scrollable (default) Grid typicall
26
26
27
27
* When no column widths are set, the available width is distributed evenly between all Grid columns.
28
28
29
-
* To allow the users to auto-fit the column widths to the content, enable [column resizing]({%slug components/grid/columns/resize%}) - a double click on the border between the headers will have the grid adjust the column width according to the size of the data, headers and footers content.
29
+
* To allow the users to auto-fit the column widths to the content, enable [column resizing]({%slug components/grid/columns/resize%}) - a double click on the border between the headers will have the grid adjust the column width according to the size of the data, headers and footers content. It is also possible to [auto-fit columns programmatically]({%slug components/grid/columns/resize%}#autofit-columns).
Copy file name to clipboardExpand all lines: components/treelist/columns/resize.md
+58-13Lines changed: 58 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,32 +10,82 @@ position: 3
10
10
11
11
# Resize Columns
12
12
13
-
The treelist lets the user resize its columns by dragging the borders between their headers.
13
+
The TreeList features two different column resizing mechanisms:
14
+
15
+
*[Resize by Dragging](#resize-by-dragging)
16
+
*[Fit to Content](#autofit-columns)
17
+
18
+
The [example at the end of this page](#example) shows both options in action.
19
+
20
+
## Resize by Dragging
21
+
22
+
The TreeList allows users to resize columns by dragging the borders between header cells.
14
23
15
24
To enable the column resizing, set the `Resizable` parameter of the treelist to `true`.
16
25
17
26
To prevent the user from resizing a certain column, set its own parameter `Resizable="false"`. Note that the user can still resize other columns around it.
18
27
19
-
When column resizing is enabled, a double click on the resize handle between the header cells will automatically fit the column width to the content of the header and data.
28
+
## Autofit Columns
29
+
30
+
When column resizing is enabled, a double click on the resize handle between the header cells will automatically fit the column width to the content of the header, data and footers. This will remove text wrapping in the component.
31
+
32
+
The TreeList also exposes methods to programmatically resize columns to fit their contents:
33
+
34
+
*`AutoFitColumn(string id)` - autofits the column with the specified `Id` attribute;
35
+
*`AutoFitColumns(IEnumerable<string> ids)` - autofits multiple columns at once;
36
+
*`AutoFitAllColumns()` - autofits all applicable columns (for example, this method does not affect the hierarchy expand/collapse column);
37
+
38
+
Autofitting specific columns preserves the current widths of all the other columns. Similar to [column resizing](#resize-by-dragging), column autofitting can trigger a horizontal Grid scrollbar, or leave empty space after the last column.
39
+
40
+
Programmatic autofitting works even if column resizing is disabled.
41
+
42
+
## Example
43
+
44
+
>caption How column resizing works in the Telerik TreeList
45
+
46
+

47
+
20
48
21
-
>caption Enable column resizing in Telerik treelist
49
+
>caption TreeList Column Resizing and Autofitting
22
50
23
51
````CSHTML
24
-
@* Drag the border between column headers to change the column size. You cannot resize the ID column itself. *@
52
+
@* TreeList column resizing and autofitting *@
53
+
@* Drag the border between column headers to change the column width. You cannot resize the ID column itself. *@
25
54
26
-
<TelerikTreeList Data="@Data" Resizable="true"
55
+
<TelerikButton OnClick="@AutoFitSingleColumn">AutoFit Name Column</TelerikButton>
56
+
<TelerikButton OnClick="@AutoFitMultipleColumns">AutoFit Id and ParentId Columns</TelerikButton>
57
+
<TelerikButton OnClick="@AutoFitAllColumns">AutoFit All Columns</TelerikButton>
Copy file name to clipboardExpand all lines: components/treelist/columns/width.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ With regard to the widths of its columns, the scrollable (default) treelist typi
24
24
25
25
* When no column widths are set, the available width is distributed evenly between all treelist columns.
26
26
27
-
* To allow the users to auto-fit the column widths to the content, enable [column resizing]({%slug treelist-columns-resize%}) - a double click on the border between the headers will have the treelist adjust the column width according to the size of the data, and header content.
27
+
* To allow the users to auto-fit the column widths to the content, enable [column resizing]({%slug treelist-columns-resize%}) - a double click on the border between the headers will have the treelist adjust the column width according to the size of the data, and header content. It is also possible to [auto-fit columns programmatically]({%slug treelist-columns-resize%}#autofit-columns).
0 commit comments