window.onload = function() {
var viewModel = {
treeListOptions: {
dataSource: {
load: function(options) {
return $.ajax({
url: "https://js.devexpress.com/Demos/Mvc/api/treeListData",
dataType: "json",
data: { parentIds: options.parentIds.join(",") }
});
}
},
remoteOperations: {
filtering: true
},
keyExpr: "id",
parentIdExpr: "parentId",
hasItemsExpr: "hasItems",
rootValue: "",
showBorders: true,
columns: [
{ dataField: "name" },
{ dataField: "size", width: 100,
customizeText: function(e) {
if(e.value !== null) {
return Math.ceil(e.value / 1024) + " KB";
}
}
},
{ dataField: "createdDate", dataType: "date", width: 150 },
{ dataField: "modifiedDate", dataType: "date", width: 150 }
]
}
};
ko.applyBindings(viewModel, document.getElementById("treelist"));
};
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.5/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.5/css/dx.light.css" />
<script src="https://cdn3.devexpress.com/jslib/20.2.5/js/dx.all.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script src="index.js"></script>
</head>
<body class="dx-viewport">
<div class="demo-container">
<div id="treelist" data-bind="dxTreeList: treeListOptions"></div>
</div>
</body>
</html>
#treelist {
max-height: 440px;
}