請嘗試使用下面的代碼片段。
<head>
<title>Test</title>
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.1.318/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.1.318/js/kendo.all.min.js"></script>
<script type="text/javascript">
var data = [
{ "make": "Audi", "model": "A1" },
{ "make": "Audi", "model": "A2" },
{ "make": "Audi", "model": "A3" },
{ "make": "Audi", "model": "A4" },
{ "make": "Saab", "model": "S500" }
];
$(document).ready(function() {
$("#grid").kendoGrid({
dataSource: {
data: data
},
columns: [{
field: "make",
title: "make"
}, {
field: "model",
title: "model"
}]
});
makesDatasource = new kendo.data.DataSource({
data: $("#grid").data("kendoGrid").dataSource.data(),
group: { field: "make", value: "make" }
});
var makes = $("#makes").kendoDropDownList({
optionLabel: "Select make...",
dataTextField: "value",
dataValueField: "value",
dataSource: makesDatasource
}).data("kendoDropDownList");
});
</script>
</head>
<body>
<div>
<div id="grid">
</div>
<div id="makes">
</div>
</div>
</body>
由於某種原因自動完成控制未在我的系統工作,所以我提供的演示爲DropDownList控制相關。請在下拉列表控件中檢查數據源和datatextfield。您必須在自動完成控制中添加相同的屬性。
讓我知道是否有任何問題。