[英]How to create Grid with with nested DropDownList in C# / Razor / KendoUI?
我將下面所附的網格從JavaScript重新鍵入到Razor,但是例如,列“ ActorInvoicingParamsFreePeriod”包含DropDownList。 我無法將其附加到網格。 我僅在JavaScript或沒有Kendo UI的情況下找到示例。 我可以編碼網格,而不是DropDownList。 你能幫助我嗎?
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 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.