簡體   English   中英

Javascript Kendo Grid“無法讀取null的屬性'length'”錯誤

[英]Javascript Kendo Grid “Cannot read property 'length' of null” Error

我有一個可擴展的劍道網格,它從不同實體分組的兩個存儲過程中返回數據。 但是,它僅返回三個實體之一的有效負載列中的數據。 在開發人員控制台中進行調試時,它返回“無法讀取null的屬性'length'。 我已經注釋了似乎導致該錯誤的代碼行。 我不確定為什么它只會對三個實體值之一執行此操作,但是我想知道是否有人建議作為我的初學者解決。 請讓我知道,謝謝!

function InitiateGrid(e) {        
        var grid = e.detailRow.find(".entityDetail").kendoGrid({
            dataSource: {
                type: "json",
                transport: {
                    read: function (option) {
                        $.ajax({
                            contentType: "json",
                            url: "/Test.svc/json/GetDetail",
                            success: function (result) {
                                option.success(result.Response); //error happening within this line of code
                            },
                            error: function (result) {
                                option.error(result.Response);
                            },
                            data: {
                                entityId: function () { return $("#txtEntityId").val(); },
                                entityTypeName: function () { return $("#txtEntityType").val(); }
                            }
                        });
                    }
                },
                schema: {
                    model: {
                        fields: {
                            Number: { type: "string", editable: false, nullable: true },
                            Id: { type: "string", editable: false },
                        }
                    }
                },
            },
            scrollable: true,
            sortable: true,
            pageable: false,
            selectable: "row",
            columns: [
                {
                    filterable: false,
                    title: "Number",
                    field: "Number",
                    width: 25,
                },
                {
                    filterable: false,
                    field: "Id",
                    title: "Id",
                    width: 25,
                }
            ]
        });
    }

Kendo Data Source內不需要其他Ajax請求。

transport: {
   read: {
      url: "/Test.svc/json/GetDetail",
      type: "get",
      dataType: "json",
      data: {
         entityId: function () { return $("#txtEntityId").val(); },
         entityTypeName: function () { return $("#txtEntityType").val(); }
      }
   },

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM