次のように定義された、列の 1 つのエディターとしてドロップダウン選択を使用しようとしています。
function phoneTypeEditor(container, options) {
$('<input required name="' + options.field + '" data-text-field="typeName" data-value-field="typeId" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: [
{
"typeName": "Work",
"typeId": 1
},
{
"typeName": "Branch",
"typeId": 2
},
{
"typeName": "Home",
"typeId": 3
},
{
"typeName": "Mobile",
"typeId": 4
}
],
close: function()
{
}
});
}
私のモデルには次のものがあります。
model: {
id: 'phoneId',
fields: {
phoneId: {
type: 'number'
},
type: {
type: 'string',
editable: true,
defaultValue: {
typeId: 1,
typeName: "Work"
},
},
tel: {
type: 'string',
editable: true
}
}
}
そして最後に私のコラム:
{
field: 'typeId',
headerTemplate: '<b>Type</b>',
filterable: false,
editor: phoneTypeEditor,
width: '80px',
template: '#=typeName#'
},
しかし、グリッドに行を作成しようとすると、投稿データは次のようになります。
phoneId:0
type[typeId]:1
type[typeName]:Work
tel:
typeName:
contactId:97558
それがいつあるべきか:
phoneId:0
typeId:1
typeName:Work
tel:
typeName:
contactId:97558
そして、グリッドに細くて空の新しい行を取得します。
これを正しく機能させるにはどうすればよいですか?
PS私が持っていない場合:
typeName: {
type: 'string'
}
私のモデルでは、typeName が定義されていないというエラーが表示されます。
私は今持っています:
model: {
id: 'phoneId',
fields: {
phoneId: {
type: 'number'
},
typeId: {
type: 'number',
defaultValue: 1
},
tel: {
type: 'string',
editable: true
},
typeName: {
type: 'string',
defaultValue: 'Work',
}
}
}
と...
columns: [
{
field: 'phoneId',
headerTemplate: '<b>Phone Id</b>',
filterable: false,
width: '50px',
hidden: true
},
{
field: 'typeId',
headerTemplate: '<b>Type</b>',
filterable: false,
editor: phoneTypeEditor,
width: '80px',
template: '#=typeName#'
},
{
field: 'tel',
headerTemplate: '<b>Number</b>',
filterable: false,
}
],
しかし、ドロップダウンのオプションを変更すると、変更していないように見えますが、実際にはテキストではなくアイテムの番号 ID が変更されています。typeId と typeName の両方が変更されるようにするにはどうすればよいですか?