亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

默認情況下如何將空的最后一行添加到 Kendo Ui 網格

默認情況下如何將空的最后一行添加到 Kendo Ui 網格

MMMHUHU 2023-09-28 17:10:16
默認情況下,我需要在編輯模式下將空的最后一行添加到 Kendo UI 網格。我正在從 api 獲取數據,如果我嘗試最后添加空行,它首先被調用,然后 api 被調用。我該怎么做。我不想設置超時。我嘗試在數據源中添加空記錄,但為此我需要做很多事情var dataSource = new kendo.data.DataSource({                type: "odata",                serverPaging: false,                serverSorting: false,                serverFiltering: false,                //pageSize: 20,                schema: {                    data: function (data) {                        var resultData = [];                        if (data.value != null && data.value[0].Payload != null && data.value[0].Payload != "[]")                            resultData = JSON.parse(data.value[0].Payload);                        return resultData;                    },                    total: function (data) {                        var length = 0;                        if (data.value != null)                            length = data.value[0].PayloadCount;                       return length;                    },                    model: {                        id: that.gridProperties.PrimaryKeyName,                        fields: that.gridProperties.Schema                    }                },                change: that.onGridDataChanged,                transport: {                    read: {                        url: that.gridProperties.DataSourceURL,                        contentType: "application/json; charset=utf-8",                        type: "GET",                        dataType: "json"                    }                }            });         
查看完整描述

2 回答

?
慕標5832272

TA貢獻1966條經驗 獲得超4個贊

您可以使用 requestEnd 設置數據源,以在網格行數據的末尾添加一個空行。


        dataSource: {

            type: "GET",

            dataType: "json",

            transport: {

                read: "url"

            },

            requestEnd: function(e) {

              e.response.d.results.push({Field: ''});

            }

        }

此外,這會導致空單元格的行為不同并且高度較小,您可以通過添加以下 css 來解決這個問題。


        .k-grid tr{height: 33px;}


查看完整回答
反對 回復 2023-09-28
?
臨摹微笑

TA貢獻1982條經驗 獲得超2個贊

嘗試使用 dataSource 的requestEnd事件。您可以在數據列表的末尾添加一個空行:

<!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>



查看完整回答
反對 回復 2023-09-28
  • 2 回答
  • 0 關注
  • 153 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號