4
我試圖在我的網格中使用下拉列表。這是我的網格定義:網格中的Kendo DropDownList在選擇後顯示值
$("#grid").kendoGrid({
editable: true,
dataSource: {
data: data,
schema: {
model: {
fields: {
Name: {
type: "string",
editable: false
},
FruitName: {
type: "string"
},
FruitID: {
type: "number"
}
}
}
}
},
columns: [{
field: "Name",
title: "Name",
width: 150
}, {
field: "Fruit",
title: "Fruit",
width: 115,
editor: renderDropDown,
template: "#=FruitName#"
}]
});
這是我的編輯功能:
function renderDropDown(container, options) {
var dataSource = [
//{ name: "", id: null },
{
FruitName: "Apple",
FruitID: 1
}, {
FruitName: "Orange",
FruitID: 2
}, {
FruitName: "Peaches",
FruitID: 3
}, {
FruitName: "Pears",
FruitID: 4
}];
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
dataTextField: "FruitName",
dataValueField: "FruitID",
dataSource: dataSource
});
}
這裏是爲了說明在JSBin演示:http://jsbin.com/malev/3/edit
煤礦是一個2部分的問題。
爲什麼這個樣本中的下拉列表在編輯之前默認沒有列中的值?
爲什麼選擇後文本切換到值?