这让我发疯了。我正在尝试做一些应该不费吹灰之力但有很多问题的事情。我有两个布尔字段,我想将它们绑定到一个带有 Yes 和 No 的组合框。我想使用 Kendo UI 组合框,并且我在 Kendo UI 网格的弹出模板中执行所有这些操作。
在下面的代码片段中,我有两个选择(在模板的末尾),一个设置了 data-role="dropdownlist",另一个没有。
第一个选择 ReceiveEmailMontlyFlyer 将在您编辑用户时选择正确的值,但不会更改它应该绑定的值。第二个选择 ReceiveEmailMessages 不会选择正确的值或返回正确的值。
请帮忙。我一定错过了一些非常简单的东西,一些我不知道或不理解的关于 HTML 5 绑定或剑道的规则。
<script id="popupEditorTemplate" type="text/x-kendo-template">
<div class="k-edit-label">
<label for="Username" class="required">Username</label>
</div>
<input type="text" class="k-input k-textbox" name="Username" data-bind="value:Username">
<div class="k-edit-label">
<label for="FirstName" class="required">First Name</label>
</div>
<input type="text" class="k-input k-textbox" name="FirstName" data-bind="value:FirstName">
<div class="k-edit-label">
<label for="LastName" class="required">Last Name</label>
</div>
<input type="text" class="k-input k-textbox" name="LastName" data-bind="value:LastName">
<div class="k-edit-label">
<label for="Email" class="required">Email</label>
</div>
<input type="text" class="k-input k-textbox" name="Email" data-bind="value:Email">
<div class="k-edit-label">
<label for="HomePhone">Home Phone</label>
</div>
<input type="text" class="k-input k-textbox" name="HomePhone" data-bind="value:HomePhone">
<div class="k-edit-label">
<label for="WorkPhone">Work Phone</label>
</div>
<input type="text" class="k-input k-textbox" name="WorkPhone" data-bind="value:WorkPhone">
<div class="k-edit-label">
<label for="MobilePhone">Mobile Phone</label>
</div>
<input type="text" class="k-input k-textbox" name="MobilePhone" data-bind="value:MobilePhone">
<div class="k-edit-label">
<label for="Line1" class="required">Address Line 1</label>
</div>
<input type="text" class="k-input k-textbox" name="Line1" data-bind="value:Line1">
<div class="k-edit-label">
<label for="Line2">Address Line 2</label>
</div>
<input type="text" class="k-input k-textbox" name="Line2" data-bind="value:Line2">
<div class="k-edit-label">
<label for="ReceiveEmailMontlyFlyer">Receive Flyer</label>
</div>
<select name="ReceiveEmailMontlyFlyer" id="ReceiveEmailMontlyFlyer" data-bind="value:ReceiveEmailMontlyFlyer">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<div class="k-edit-label">
<label for="ReceiveEmailMessages">Receive other</label>
</div>
<select id="ReceiveEmailMessages" name="ReceiveEmailMessages" data-bind="value:ReceiveEmailMessages" data-role="dropdownlist">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<br />
</script>