autoFitColumn
Applies the minimum possible width for the specified column so that all the text fits without wrapping.
Parameters
column Number|String|Object
The index of the column, the field to which the columns is bound, or the column object that is obtained from the columns collection.
Example - automatically fitting a column by an index
<div id="treeList"></div>
<script>
$("#treeList").kendoTreeList({
resizable: true,
columns: [
{ field: "Name" },
{ field: "Position" }
],
dataSource: [
{ id: 1, Name: "Daryl Sweeney", Position: "CEO", parentId: null, expanded: true },
{ id: 2, Name: "Guy Wooten", Position: "Chief Technical Officer", parentId: 1 }
]
});
var treeList = $("#treeList").data("kendoTreeList");
treeList.autoFitColumn(1);
</script>
Example - automatically fitting a column by a field
<div id="treeList"></div>
<script>
$("#treeList").kendoTreeList({
resizable: true,
columns: [
{ field: "Name" },
{ field: "Position" }
],
dataSource: [
{ id: 1, Name: "Daryl Sweeney", Position: "CEO", parentId: null, expanded: true },
{ id: 2, Name: "Guy Wooten", Position: "Chief Technical Officer", parentId: 1 }
]
});
var treeList = $("#treeList").data("kendoTreeList");
treeList.autoFitColumn("Position");
</script>
Example - automatically fitting a column by a column object reference
<div id="treeList"></div>
<script>
$("#treeList").kendoTreeList({
resizable: true,
columns: [
{ field: "Name" },
{ field: "Position" }
],
dataSource: [
{ id: 1, Name: "Daryl Sweeney", Position: "CEO", parentId: null, expanded: true },
{ id: 2, Name: "Guy Wooten", Position: "Chief Technical Officer", parentId: 1 }
]
});
var treeList = $("#treeList").data("kendoTreeList");
treeList.autoFitColumn(treeList.columns[1]);
</script>