如何在C#/ Razor / KendoUI中使用嵌套的DropDownList创建网格?

ŁukaszSpuziak

我将下面所附的网格从JavaScript重新键入到Razor,但是例如,列“ ActorInvoicingParamsFreePeriod”包含DropDownList。我无法将其附加到网格。我仅在JavaScript或没有Kendo UI的情况下找到示例。我可以对DropoutList进行网格编码。你能帮助我吗?

    function populateGridWithInvoicingMethod() {
        $("#grid").show();
        $("#grid").html("");
        $("#grid").kendoGrid({
            columns: [
            {
                field: "Name",
                title: "@CTA.DealerName",
            width: 100,
        },
        {
            field: "InvoicingPeriod",
            title: "@CTA.InvoicingMethod",
            values: InvoicingMethodEnumArray,
            editor: invoicingMethodDropDownEditor,
            width: 50
        },
        {
            field: "ActorInvoicingParamsNumberOfMonths",
            title: "@CTA.NumberOfMonths",
            format: "{0:d}",
            width: 30
        },
        {
            field: "ActorInvoicingParamsFreePeriod",
            title: "@CTA.StandardPackageFreeInvoicingPeriod",
            values: FreeInvoicingPeriodArray,
            editor: freeinvoicePeriodDropDownEditor,
            template: "#= ActorInvoicingParamsFreePeriod != -1 ? ActorInvoicingParamsFreePeriod : 'Not set' #",
            width: 30
        },
        {
            field: "ParentActorActorId",
            title: "@CTA.InvoicingRegion",
            values: InvoicingRegionArray,
            width: 30
        },
        {
            field: "ExportToGlif",
            title: "@CTA.ExportToGlif",
            template: '<input class="checkbox" type="checkbox" #= ExportToGlif ? checked="checked" : "" # disabled="disabled"/>',
            width: 20
        }
        ],
        dataSource: {
            transport: {
                read: {
                    url: baseUrl + "api/PriceListApi/GetInvoicingMethodList",
                    dataType: "json",
                    type: "POST",
                    contentType: "application/json; charset=utf-8"
                },
                update: {
                    url: baseUrl + "api/PriceListApi/UpdateInvoicingMethodList",
                    dataType: "json",
                    async: false,
                    type: "POST",
                    contentType: "application/json; charset=utf-8"
                },
                parameterMap: function (options, operation) {
                    if (operation !== "read" && options) {
                        return kendo.stringify(options);
                    } else {
                        return kendo.stringify(createInvoicingMethodRequest());
                    }
                }
            },
            schema: {
                model: {
                    id: "ActorId",
                    fields: {
                        Name: { editable: false },
                        ExportToGlif: { editable: false },
                        InvoicingPeriod: { editable: false },
                        ActorInvoicingParamsNumberOfMonths: { editable: false, type: "number" },
                        ActorInvoicingParamsFreePeriod: { editable: false, type: "number" },
                        ParentActorActorId: { editable: false, type: "number" }
                    }
                },
                data: function (response) {
                    var dataForDataSource = [];
                    var len = response.length;
                    for (var i = 0; i < len; i++) {
                        var obj = response[i];
                        obj.ParentActorActorId = obj.ParentActorActorId != null ? obj.ParentActorActorId : -1;
                        obj.ActorInvoicingParamsFreePeriod = obj.ActorInvoicingParamsFreePeriod != null ? obj.ActorInvoicingParamsFreePeriod : -1;
                        dataForDataSource.push(obj);
                    }
                    return dataForDataSource;
                },
            },
            error: onGridDataSourceError
        },
        onError: onGridError,
        editable: true,
        selectable: true,
        scrollable: false,
        pageable: {
            refresh: true,
            pageSize: 10
        }
    });
}
尼古拉斯

您可以通过添加外键列来实现。

有关示例,请参见http://demos.telerik.com/aspnet-mvc/grid/foreignkeycolumn

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章