我有一个局部视图可以用来将剑道下拉列表绑定到远程数据源。我认为部分重复使用了5次。我将该值传递给Controller方法,以便为控件的每个实例动态绑定数据(就像在ascx文件中所做的一样)。
我的问题是,对于这些下拉列表中的2个,整个列表会按选择返回。我还没有将数据绑定到来自模型实例的模型视图数据中,此时只是空白表格。
这是我呈现的HTML剑道下拉列表之一,其中存在以下问题:
<ul tabindex="-1" class="k-list k-reset" id="Title_listbox" role="listbox" aria-hidden="true" aria-live="off" data-role="staticlist" unselectable="on">
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="0"></li>
<li tabindex="-1" class="k-item k-state-selected k-state-hover" role="option" aria-selected="true" unselectable="on" data-offset-index="1">Attorney</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="2">CEO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="3">CFI</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="4">CFO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="5">Chairman</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="6">Chairperson</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="7">Consultant</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="8">COO</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="9">Coordinator</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="10">CPA</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="11">Director</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="12">EVP</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="13">Executive</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="14">Judge</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="15">Manager</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="16">Owner</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="17">Partner</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="18">President</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="19">Principal</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="20">Superintendant</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="21">Supervisor</li>
<li tabindex="-1" class="k-item k-state-selected" role="option" aria-selected="true" unselectable="on" data-offset-index="22">Treasurer</li>
<li tabindex="-1" class="k-item k-state-focused" id="970fd67b-52fe-4519-b2f8-36cae7068b32" role="option" aria-selected="false" unselectable="on" data-offset-index="23">Vice President</li>
这是我的部分查看代码:
<script type="text/javascript">
function LookupInfo(lookupID) { return { LookupTypeID: lookupID }; }
function LookupInfo_DataBound() { this.value("@Model.SelectedLookupID"); }
</script>
<div class="editor-field">
@(Html.Kendo().DropDownList()
.Name(@Model.LookupName)
.HtmlAttributes(new { @id = Model.LookupName.ToString(), @class = "myclass" })
.DataTextField("Name")
.DataValueField("Value")
.SelectedIndex(@Model.SelectedLookupID)
.Events(events => events.DataBound("LookupInfo_DataBound"))
.DataSource(dataSource => dataSource
.Read(read => read.Action("GetLookup", "Contact").Data("LookupInfo("+@Model.LookupTypeID+")")
)
)
)
</div>
我尝试提供.SelectedIndex(0),但是那没用!
事件调用至少在这样做方面有好处,因为呈现的结果现在不会将列表中的最后一项显示为选定项。
对于使用jQuery“解决”问题,我没有什么解决方案。
未发布我的控制器代码,因为它与此处无关。在所有5种情况下,数据都是具有约束力的,除了两个列表中的所有项都被选中之外。