Kendo可编辑网格,单击添加新行可重置下拉菜单 [英] Kendo editable grid, drop-down resets on click of add new row
本文介绍了Kendo可编辑网格,单击添加新行可重置下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可编辑的剑道网格,在该列中有一个下拉菜单.单击"AddNew"后,上一个记录中的下拉列表将为空.我创建了DOJO,可以重现此问题.请帮忙.任何帮助将不胜感激.
DOJO链接: [
I have a kendo editable grid, where I have a drop-down in one the column. On click of ''AddNew'' the drop-down in the previous record gets empty. I have created DOJO where this issue can be reproduced. Please help. Any help would be highly appreciated.
DOJO link: [^]
What I have tried:
<div ng-controller="stockController">
<br /><br />
<div kendo-grid="stockGrid"
options="stockGridOptions"></div>
</div>
<script>
angularApp.controller(''stockController'', function ($scope, $http) {
function readOnly(container, options) {
container.removeClass("k-edit-cell");
container.text(options.model.get(options.field));
}
$scope.stockGridOptions = {
toolbar: ["create", "save", "cancel"],
dataSource: {
transport: {
create: {
url: "/Stock/InsertStockDetails",
type: "post",
complete: function (e) {
$scope.stockGrid.dataSource.data([]);
PopupSuccess(e.responseJSON.Message, 4000);
}
},
parameterMap: function (options, operation) {
if (operation !== "read" && options.models) {
angular.forEach(options.models, function (value) {
value.Mfg_Dt = kendo.toString(value.Mfg_Dt, "s");
value.Exp_Dt = kendo.toString(value.Exp_Dt, "s");
})
return options;
}
}
},
batch: true,
schema: {
model: {
id: "Id",
fields: {
Id: { type: "number", editable: false },
Product_Name: { type: "string", validation: { required: true } },
Product_Type: { editable: false, defaultValue: { Text: "None", Value: 0 } },
Batch_No: {type: "string", validation: {required: true}},
Mfg_Dt: { type: "date", validation: { required: true }, nullable: true },
Exp_Dt: { type: "date", validation: { required: true }, nullable: true },
Strip_No: { type: "number", validation: { required: true } },
Strip_Unit: { type: "number", validation: { required: true } },
Total: { type: "number" },
}
}
},
change: function (e) {
if (e.action === "itemchange" && e.field === "Strip_No" || e.field === "Strip_Unit") {
var totalValue = e.items[0].Strip_No * e.items[0].Strip_Unit;
e.items[0].set(''Total'', totalValue);
}
}
},
autoBind: false,
columns: [{
field: "Product_Name",
title: "Product Name"
}, {
field: "Product_Type",
title: "Product Type",
template: ''<select kendo-drop-down-list k-options="typeOptions" style="width: 100%"></select>''
},{
field: "Batch_No",
title: "Batch No"
},{
field: "Mfg_Dt",
title: "Mfg Dt",
format: "{0:dd-MM-yyyy}"
},{
field: "Exp_Dt",
title: "Exp Dt",
format: "{0:dd-MM-yyyy}"
},{
field: "Strip_No",
title: "Number of Strip"
},{
field: "Strip_Unit",
title: "Units in Strip"
},{
field: "Total",
title: "Total",
editor: readOnly
}],
editable: true
};
$scope.typeOptions = {
dataSource: {
transport: {
read: {
url: "/Stock/GetProductType",
type: "get",
}
}
},
dataTextField: "Product_Type",
dataValueField: "Id",
optionLabel: "Select Type",
select: function (e) {
e.sender.$angular_scope.dataItem.Product_Type = e.dataItem.Id;
}
};
});
</script>
推荐答案
作用域,
http){ 函数readOnly(容器,选项){ container.removeClass("k-edit-cell"); container.text(options.model.get(options.field)); }
http) { function readOnly(container, options) { container.removeClass("k-edit-cell"); container.text(options.model.get(options.field)); }
scope.stockGridOptions = { 工具栏:[创建",保存",取消"], 数据源: { 运输: { 创造: { 网址:"/Stock/InsertStockDetails", 类型:"post", complete:function(e){
scope.stockGridOptions = { toolbar: ["create", "save", "cancel"], dataSource: { transport: { create: { url: "/Stock/InsertStockDetails", type: "post", complete: function (e) {
这篇关于Kendo可编辑网格,单击添加新行可重置下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文