2 回答

TA貢獻(xiàn)1966條經(jīng)驗 獲得超4個贊
您可以使用 requestEnd 設(shè)置數(shù)據(jù)源,以在網(wǎng)格行數(shù)據(jù)的末尾添加一個空行。
dataSource: {
type: "GET",
dataType: "json",
transport: {
read: "url"
},
requestEnd: function(e) {
e.response.d.results.push({Field: ''});
}
}
此外,這會導(dǎo)致空單元格的行為不同并且高度較小,您可以通過添加以下 css 來解決這個問題。
.k-grid tr{height: 33px;}

TA貢獻(xiàn)1982條經(jīng)驗 獲得超2個贊
嘗試使用 dataSource 的requestEnd
事件。您可以在數(shù)據(jù)列表的末尾添加一個空行:
<!DOCTYPE html>
<html>
<head>
? ? <base >
? ? <style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
? ? <title></title>
? ? <link rel="stylesheet" />
? ? <script src="https://kendo.cdn.telerik.com/2020.3.1118/js/jquery.min.js"></script>
? ??
? ??
? ? <script src="https://kendo.cdn.telerik.com/2020.3.1118/js/kendo.all.min.js"></script>
? ??
? ??
</head>
<body>
? ? <div id="example">
? ? <div id="grid"></div>
? ? <script>
? ? ? ? $(document).ready(function() {
? ? ? ? ? ? $("#grid").kendoGrid({
? ? ? ? ? ? ? ? dataSource: {
? ? ? ? ? ? ? ? ? ? type: "odata",
? ? ? ? ? ? ? ? ? ? transport: {
? ? ? ? ? ? ? ? ? ? ? ? read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Categories"
? ? ? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? ? ? requestEnd: function(e) {
? ? ? ? ? ? ? ? ? ? ? e.response.d.results.push({CategoryName: ''});
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? height: 550,
? ? ? ? ? ? ? ? filterable: true,
? ? ? ? ? ? ? ? sortable: true,
? ? ? ? ? ? ? ? pageable: true,
? ? ? ? ? ? ? ? columns: [
? ? ? ? ? ? ? ? ? ? "CategoryName"
? ? ? ? ? ? ? ? ]
? ? ? ? ? ? });
? ? ? ? });
? ? </script>
</div>
? ??
</body>
</html>
添加回答
舉報