从自动生成网格列中阻止Kendo [英] Stop Kendo from auto-generating grid columns

查看:99
本文介绍了从自动生成网格列中阻止Kendo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am nesting a kendo grid inside another kendo grid row as a "detail" template. I'm having this extremely frustrating issue, though; Kendo seems to be auto-generating the columns for the detail grid for me even though I have defined them myself and it's displaying a lot of columns that I don't want to be displayed.

这是原始网格:

$("#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" }
    ]
});

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

And here is my viewmodel along with the grid detail:

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网格中删除了列定义,但所有自动生成"列仍然存在.

Now the crazy part is that even if I remove the column definitions from the detail grid then all of the "auto-generated" columns are still there.

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

Here is a screenshot of what I'm getting - notice how all of the columns in the detail for the row are shown even when only 5 are defined:

有人有没有遇到过这个问题,或者对什么可能导致这个问题有任何想法?

Has anyone run into this issue before or have any ideas on what could be causing this?

推荐答案

我知道了.问题是我在的内部 而不是外部定义了网格的列和其他属性.现在一切正常.

I figured it out. The issue was that I was defining my columns and other properties of the grid inside the DataSource instead of outside of it. All is working fine now.

这篇关于从自动生成网格列中阻止Kendo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆