要有三個相關的組合框,最好使用kendo組合框的「cascadeFrom」屬性。 一個簡單的例子:
<div>
<input id="category" />
<input id="sports" />
<input id="player" />
</div>
<script>
$("#category").kendoComboBox({
dataTextField: "categoryName",
dataValueField: "categoryId",
dataSource: [
{ categoryName: "Sports", categoryId: 1 },
{ categoryName: "Music", categoryId: 2 }
]
});
$("#sports").kendoComboBox({
cascadeFrom: "category",
dataTextField: "sportsName",
dataValueField: "sportsId",
dataSource: [
{ sportsName: "Football", sportsId: 1, categoryId: 1 },
{ sportsName: "Cricket", sportsId: 2, categoryId: 1 },
{ sportsName: "Pop", sportsId: 3, categoryId: 2 },
{ sportsName: "Rock", sportsId: 4, categoryId: 2 }
]
});
$("#player").kendoComboBox({
cascadeFrom: "sports",
dataTextField: "playerName",
dataValueField: "playerId",
dataSource: [
{ playerName: "David Beckham", playerId: 1, sportsId: 1 },
{ playerName: "Leonel Messi", playerId: 2, sportsId: 1 },
{ playerName: "Xavi", playerId: 3, sportsId: 1 },
{ playerName: "Raina", playerId: 4, sportsId: 2 },
{ playerName: "Gambhir", playerId: 4, sportsId: 2 },
{ playerName: "YXZ", playerId: 4, sportsId: 3 },
{ playerName: "ABC", playerId: 4, sportsId: 3 }
]
});
// To set value in combo-box
$("#category").data('kendoComboBox').value(1);
$("#sports").data('kendoComboBox').value(1);
$("#player").data('kendoComboBox').value(2);
</script>
在這裏,我已經硬編碼在組合框中設置的值。你可以從數據庫中提取數據並在這裏設置。 它很好的保存組合框的值字段並使用它來顯示數據。
希望這會有所幫助。
Reference Link