Kendo UI Grid を使用しており、カスタム テンプレートでポップアップ編集を使用するように設定しています。
<script id="popup_editor" type="text/x-kendo-template">
<div id="editor">
<div class="k-edit-label">
<label for="Type">Type</label>
</div>
<select data-role="dropdownlist" data-value-field="Type" data-text-field="Type"
data-bind="source: typeSource, value: selectedProduct"></select>
<div class="k-edit-label">
<label for="Type">Option</label>
</div>
<select data-role="dropdownlist" data-value-field="Option" data-text-field="Option"
data-bind="source: productsSource.Options, value: selectedOption"></select>
</div>
</script>
これは私のビューモデルです:
function ViewModel() {
var getTypesUrl = "/Controller/Action";
var viewModel = kendo.observable({
typeSource: new kendo.data.DataSource({
transport: {
read: {
url: getConditionTypesUrl,
dataType: "json"
},
},
batch: true,
schema: {
model: {
id: "Type"
}
}
}),
selectedType: null,
selectedOption: null
});
kendo.bind($("#editor"), viewModel);
}
ViewModel();
私のアクションは JSON を返します。
問題は、[新しいレコードの追加] ボタンをクリックしても、への呼び出しがなくgetTypesUrl
、ドロップダウン リストにデータが入力されないことです。一般的な考え方は、タイプごとに異なるオプションを用意し、選択したタイプに応じて [オプション] ドロップダウンリストを設定することです。ボタンがクリックされたときにのみエディタが表示され、剣道がバインディングを作成できないために問題が発生すると思います。