collapse

Fires when an item is about to be collapsed. The event handler function context (available through the this keyword) will be set to the widget instance.

Event Data

e.sender kendo.ui.TreeList

The widget instance which fired the event.

e.model kendo.data.TreeListModel

The data item to which the table row is bound.

e.preventDefault Function

If invoked, prevents the collapse action. The child table rows will not be hidden.

Example - subscribing to the collapse event before initialization

<div id="treeList"></div>
 <script>
    $("#treeList").kendoTreeList({
      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 }
      ],
      collapse: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
        console.log("collapse");
      }
    });
</script>

Example - subscribing to the collapse event after initialization

<div id="treeList"></div>
 <script>
    function collapse(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
        console.log("collapse");
    }
    $("#treeList").kendoTreeList({
      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.bind("collapse", collapse);
    treeList.dataSource.fetch();
</script>
In this article