我正在使用kendo层次结构网格。我试图弄清楚如何将数据从子网格中的一行传递回我的更新函数,以便我可以更新我的数据库。
以下是我网格的代码:
$("#NewPhraseGrid").kendoGrid({
dataSource: gridNewPhraseDataSource,
columns: [
{ template: "<input type='checkbox' class='checkbox' />" },
{ field: "Status", editable: false, title: "Status" },
{ field: "PhraseCodeComputed", editable: false, title: "Phrase Code Computed" },
{ field: "PhraseText", editable: true, title: "Phrase Text" },
{ field: "Example", title: "Example" },
{ field: "NotesDesc", title: "Notes" },
{ field: "Source", title: "Source" }
],
selectable: true,
pageable: true,
detailInit: detailInit,
dataBound: function () {
this.expandRow(this.tbody.find("tr.k-master-row").first());
}
});
以下是我的子网格的代码:
function detailInit(e) {
$("<div/>").appendTo(e.detailCell).kendoGrid({
scrollable: false,
dataSource: {
type: "json",
transport: {
read: {
url: "concepts/getSimplifications",
dataType: "json",
type: "get"
},
create: {
url: "concepts/createSimplifications",
dataType: "json",
data: { "originalPhraseCodeComputed": e.data.PhraseCodeComputed },
type: "post"
},
update: {
url: "concepts/updateSimplifications",
dataType: "json",
data: { "phraseText": PhraseText, "phraseType": PhraseType },
type: "post"
}
},
schema: {
data: "data",
model: {
id: "NewPhraseCodeComputed",
fields: {
OriginalPhraseCode: { type: "string", editable: false },
NewPhrasePrefix: { type: "string", editable: false },
NewPhraseNumber: { type: "number", editable: false },
NewPhraseCodeComputed: { type: "string", editable: false },
PhraseType: { type: "string", editable: "true" },
PhraseText: {type: "string", editable: "true"}
}
}
}
},
sortable: true,
pageable: true,
toolbar: ["create"],
filter: { field: "OriginalPhraseCode", operator: "eq", value: e.data.PhraseCodeComputed },
columns: [
{ field: "NewPhraseCodeComputed", title: "New Phrase Code", width: "110px" },
{ field: "PhraseType", title: "Phrase Type", width: "110px", editor: phraseTypeDropDownEditor},
{ field: "PhraseText", title: "Phrase Text", width: "110px" },
{ command: ["edit", "destroy"], title: " ", width: "250px" }],
editable: "inline"
});
}
以下是我的自定义下拉菜单的代码:
function phraseTypeDropDownEditor(container, options) {
$('<select id= phraseTypeSelection' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "phraseType",
dataValueField: "phraseType",
dataSource: {
type: 'json',
transport: {
read: {
dataType: 'json',
url: "concepts/getPhraseTypes",
type: 'get'
}
}
}
});
};
我想将子网格中正在编辑的行的值传回Phrasetext和PhraseType列到我的网格的更新功能,但我不知道如何访问这些值。
任何人都可以提供有关如何操作的任何见解吗?
答案 0 :(得分:1)
尝试将自定义编辑器绑定到name
属性,例如
function phraseTypeDropDownEditor(container, options) {
$('<select id="phraseTypeSelection" name"' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "phraseType",
dataValueField: "phraseType",
dataSource: {
type: 'json',
transport: {
read: {
dataType: 'json',
url: "concepts/getPhraseTypes",
type: 'get'
}
}
}
});
};