Kendo ui 将数据传回更新函数
我正在使用剑道等级网格。我试图弄清楚如何将数据从子网格中的a行传递回我的更新函数,以便更新我的数据库 以下是我的网格的代码:Kendo ui 将数据传回更新函数,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我正在使用剑道等级网格。我试图弄清楚如何将数据从子网格中的a行传递回我的更新函数,以便更新我的数据库 以下是我的网格的代码: $("#NewPhraseGrid").kendoGrid({ dataSource: gridNewPhraseDataSource, columns: [ { template: "<input type='checkbox' class='checkbox' />" }, { field: "Status"
$("#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());
}
});
$(“#NewPhraseGrid”).kendoGrid({
数据源:gridNewPhraseDataSource,
栏目:[
{模板:'},
{字段:“状态”,可编辑:false,标题:“状态”},
{字段:“短语代码计算”,可编辑:false,标题:“短语代码计算”},
{字段:“短语文本”,可编辑:true,标题:“短语文本”},
{字段:“示例”,标题:“示例”},
{字段:“NotesDesc”,标题:“Notes”},
{字段:“源”,标题:“源”}
],
是的,
pageable:对,
detailInit:detailInit,
数据绑定:函数(){
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"
});
}
函数detailInit(e){
$(“”).appendTo(e.detailCell).kendoGrid({
可滚动:false,
数据源:{
键入:“json”,
运输:{
阅读:{
url:“概念/获取简化”,
数据类型:“json”,
键入:“获取”
},
创建:{
url:“概念/创建简化”,
数据类型:“json”,
数据:{“originalPhraseCodeComputed”:e.data.PhraseCodeComputed},
类型:“职位”
},
更新:{
url:“概念/更新示例”,
数据类型:“json”,
数据:{“phraseText”:phraseText,“phraseType”:phraseType},
类型:“职位”
}
},
模式:{
数据:“数据”,
型号:{
id:“NewPhraseCodeComputed”,
字段:{
原始短语代码:{type:“string”,可编辑:false},
NewPhrasePrefix:{type:“string”,可编辑:false},
NewPhraseNumber:{type:“number”,可编辑:false},
NewPhraseCodeComputed:{type:“string”,可编辑:false},
短语类型:{type:“string”,可编辑:“true”},
短语文本:{type:“string”,可编辑:“true”}
}
}
}
},
可排序:是的,
pageable:对,
工具栏:[“创建”],
筛选器:{field:“OriginalPhraseCode”,运算符:“eq”,值:e.data.PhraseCodeComputed},
栏目:[
{字段:“NewPhraseCodeComputed”,标题:“新短语代码”,宽度:“110px”},
{字段:“短语类型”,标题:“短语类型”,宽度:“110px”,编辑器:短语类型下拉编辑器},
{字段:“短语文本”,标题:“短语文本”,宽度:“110px”},
{命令:[“编辑”、“销毁”],标题:“”,宽度:“250px”}],
可编辑:“内联”
});
}
以下是我的自定义下拉编辑器的代码:
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'
}
}
}
});
};
函数短语类型下拉编辑器(容器,选项){
$('尝试将自定义编辑器绑定到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'
}
}
}
});
};
函数短语类型下拉编辑器(容器,选项){
$('')
.appendTo(容器)
.kendoDropDownList({
自动绑定:错误,
dataTextField:“短语类型”,
dataValueField:“短语类型”,
数据源:{
键入:“json”,
运输:{
阅读:{
数据类型:“json”,
url:“概念/getPhraseTypes”,
键入:“获取”
}
}
}
});
};
搞定了,卡拉。谢谢!