使用模板和放大器;在网格列编辑与角剑道UI [英] Using templates&editors in grid column with Angular Kendo UI
本文介绍了使用模板和放大器;在网格列编辑与角剑道UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用角剑道UI在我的应用程序。一些观点包括电网。
I'm trying to use Angular Kendo UI in my app. Some views include grid.
<div kendo-grid
k-sortable ="true"
k-pageable ="true"
k-filterable ="true"
k-resizable ="true"
k-editable = "'incell'"
k-selectable = "true"
k-options = "accountSettingsDS"
k-columns = '[
{ field: "Companies", title: "Companies", editor : "<input kendo-drop-down-list k-data-text-field=\"'name'\" k-data-value-field=\"'name'\" k-data-source=\"CompaniesList\" ng-model=\"dataItem.Companies\"/>"},
{ field: "Currency", title: "Currency", editor : "<input kendo-drop-down-list k-data-text-field=\"'name'\" k-data-value-field=\"'name'\" k-data-source=\"CurrenciesList\" ng-model=\"dataItem.Currency\"/>"},
{ field: "Account", title: "Account", editor : "<input kendo-drop-down-list k-data-text-field=\"'name'\" k-data-value-field=\"'name'\" k-data-source=\"AccountsList\" ng-model=\"dataItem.Account\"/>"},
{ field: "NCAccount", title: "NCAccount", editor : "<input kendo-drop-down-list k-data-text-field=\"'name'\" k-data-value-field=\"'name'\" k-data-source=\"NCAccountsList\" ng-model=\"dataItem.NCAccount\"/>"}
]'
k-toolbar="['save','cancel']"
id="accountSettingsGrid">
</div
有关该网格的DataSource在code定义如下图所示。
DataSource for this grid is defined like in code below
$scope.accountSettingsDS = {
dataSource: {
serverPaging: true,
serverFiltering: true,
serverSorting: true,
pageSize: 10,
type: "odata",
schema: {
data: function (response) {
if (response.value !== undefined)
return response.value;
else {
delete response["odata.metadata"];
return response;
}
},
total: function (response) {
return response['odata.count'];
},
model: {
id: "id",
fields: {
id: {
type: "number",
editable: false
},
Companies: {
type: "string",
editable: true
},
Currency: {
type: "string",
editable: true
},
Account: {
type: "string",
editable: true
},
NCAccount: {
type: "string",
editable: true
}
}
}
},
transport: {
read: {
url: serviceUrl + "AccountsSettings",
dataType: "json"
},
create: {
url: serviceUrl + "AccountsSettings",
type: "POST",
contentType: "application/json"
},
update: {
url: function(record) {
return serviceUrl + "AccountsSettings" + "(" + record.id + ")";
},
type: "PUT",
contentType: "application/json",
dataType: "json",
headers: { Prefer: "return-content" }
},
destroy: {
url: function(record) {
return serviceUrl + "AccountsSettings" + "(" + record.id + ")";
},
type: "DELETE",
contentType: "application/json",
dataType: "json"
},
parametermap: function (data, operation) {
console.log(data);
if (operation === "read") {
var parammap = kendo.data.transports.odata.parametermap(data);
return parammap;
}
return json.stringify(data);
}
}
}
};
当我编辑的网格项,然后点击保存更改按钮,没有任何反应。结果
如果我正确定义网格列没有编辑,然后数据更新(这样我必须使用默认字符串编辑器)。但我需要自定义编辑器。结果
我怎样才能解决这个问题呢?
When I edit grid item and click "Save changes" button nothing happens.
If I define grid columns without editors then data updates correctly(in this way I have to use default string editor). But I need custom editors.
How can I resolve this problem?
推荐答案
尽量给name属性编辑器输入,因此电网会知道要更新的模型的属性。
Try to give name attribute to the editor input, so the Grid will know which property of the model to update.
input kendo-drop-down-list name='Account' ...
这篇关于使用模板和放大器;在网格列编辑与角剑道UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文