【发布时间】:2013-12-05 02:12:06
【问题描述】:
我们正在使用基于服务器的简单网格。网格读取和更新远程数据源的数据。它有两列使用下拉编辑器。一切似乎都工作正常,除了保存后,当编辑器关闭时,更改的值不会显示在编辑的行中。它仍然显示旧值。当我们尝试使用同步事件刷新网格时,它会更改行的顺序,但是,它会在刷新时更新值。
更新完成后好像没有执行模板功能。如何编辑网格/代码以确保更改的值反映在网格中?
网格定义代码:
$("#servicetype-grid").kendoGrid({
pageable: true,
toolbar: [{name: "create", text: ""}, { template: kendo.template($("#servicetype-search-template").html())}],
columns: [
{
field: "serviceName", title: "Service Name"
},
{
field: "billCalculationTypeId",
editor: calculationTypeDropDownEditor,
template: function(dataItem) {
return kendo.htmlEncode(dataItem.billCalculationTypeName);
},
title: "Bill Calculation Type"
},
{
field: "payCalculationTypeId",
editor: calculationTypeDropDownEditor,
template: function(dataItem) {
return kendo.htmlEncode(dataItem.payCalculationTypeName);
},
title: "Pay Calculation Type"
},
{
command: [
{ name: "edit", text: { edit: "", cancel: "", update: "" }},
{ name: "destroy", text:""}
],
title: "Actions"
}
],
dataSource: dataSource,
sortable: {
mode: "single",
allowUnsort: false
},
dataBound: function(e) {
setToolTip();
},
edit: function(e) {
$('.k-grid-update').kendoTooltip({content: "Update"});
$('.k-grid-cancel').kendoTooltip({content: "Cancel"});
},
cancel: function(e) {
setToolTip();
},
editable: {
mode: "inline",
confirmation: "Are you sure that you want to delete this record?"
}
});
下拉功能定义为:
function calculationTypeDropDownEditor(container, options) {
$('<input required data-text-field="name" data-value-field="id" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
transport: {
read: {
dataType: "jsonp",
url: baseURL + "rips/services/calculationType/lookupList"
}
}
}
});
}
【问题讨论】:
-
我看到缺少的一件事是您没有定义模式。看看这个例子jsbin.com/eyebub/8/edit
-
该示例用于弹出编辑,但逻辑也应适用于您的案例
-
我在定义网格时找到了使用模板定义的解决方案。但是,在添加内联记录时我仍然遇到问题。服务器正在正确返回数据,但未反映在新添加的行中。