【问题标题】:Stop Kendo from auto-generating grid columns阻止 Kendo 自动生成网格列
【发布时间】:2017-06-15 23:34:13
【问题描述】:

我将剑道网格嵌套在另一个剑道网格行中,作为“详细信息”模板。不过,我遇到了这个非常令人沮丧的问题; Kendo 似乎正在为我自动生成详细信息网格的列,即使我自己定义了它们并且它显示了很多我不想显示的列。

这是原始网格:

$("#ResellerBillingGrid").kendoGrid({
    dataSource: viewModel.resellerDataSource,
    editable: false,
    groupable: false,
    sortable: true,
    pageable: true,
    scrollable: false,
    filterable: {
        extra: false,
        messages: {
            isTrue: "Yes",
            isFalse: "No",
            info: " "
        }
    },
    filterMenuInit: filterMenuInit,
    detailTemplate: kendo.template($("#resellerDetailTemplate").html()),
    detailInit: viewModel.detailInit,
    columns: [
        { field: "DisplayName", title: "Reseller" }
    ]
});

这是我的视图模型以及网格细节:

var viewModel = new kendo.observable({
    resellerDataSource: new kendo.data.DataSource({
        transport: {
            read: {
                url: "/Host/Billing/GetResellers",
                dataType: "json",
                type: "GET"
            }
        },
        pageSize: 20,
        schema: {
            model: {
                fields: {
                    DisplayName: { type: "string" },
                    ResellerOrganizationsDataSource: [
                        {
                            Id: { type: "number" },
                            OrgDisplay: { type: "string" },
                            UserCount: { type: "number" },
                            PricingTier: {
                                Id: { type: "number" },
                                Name: { type: "string" },
                                PricePerUser: { type: "number" },
                                Total: { type: "number" }
                            }
                        }
                    ]
                }
            }
        }),
        detailInit: function (e) {
            var detailRow = e.detailRow;

            detailRow.find(".resellerOrgsGrid").kendoGrid({
                dataSource: {
                    data: e.data.ResellerOrganizationsDataSource,
                    pageSize: 10,
                    schema: {
                        model: {
                            fields: {
                                Id: { type: "number" },
                                OrgDisplay: { type: "string" },
                                UserCount: { type: "number" },
                                PricingTier: {
                                    Id: { type: "number" },
                                    Name: { type: "string" },
                                    PricePerUser: { type: "number" },
                                    Total: { type: "number" }    
                                }
                            }
                        }
                    }
                },
                scrollable: false,
                sortable: true,
                pageable: true,
                columns: [
                    { field: "OrgDisplay", filterable: { ui: orgFilter }, title: "Name" },
                    { field: "PricingTier.Name, title: "Pricing Tier", filterable: { ui: tierFilter } ),
                    { field: "PricingTier.PricePerUser", title: "Price Per User", format: "{0:C2}" },
                    { field: "UserCount", title: "Total Users" },
                    { field: "PricingTier.Total", title: "Total", format: "{0:C2}" }
                ]
            }
        });
    }
});

现在最疯狂的是,即使我从detail 网格中删除列定义,所有“自动生成”列仍然存在。

这是我得到的屏幕截图 - 请注意即使只定义了 5 列,该行的详细信息中的所有列也是如何显示的:

之前有没有人遇到过这个问题,或者对导致这个问题的原因有任何想法?

【问题讨论】:

    标签: javascript mvvm kendo-ui kendo-grid


    【解决方案1】:

    我想通了。问题是我在DataSource 内部而不是外部定义我的列和网格的其他属性inside。现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多