我真的很为寻找解决方案来显示顶部列表框中的选定项目。 我在这里使用敲除来绑定我的列表框。该列表框在我看来将选定的项目移到列表框顶部
<select id ="multiAltVersion" multiple="multiple" data-bind="options: $root.editOnlyAlternativeVersions, optionsText: 'PlatformVersionName',optionsValue: 'Id',selectedOptions: $root.copiedAltVersion, chosen: true "> </select>
我打电话给我的WCF服务填写列表框,如下绑定。
function loadVersionListByProductType(prodtype) {
var input =
{
ProductType: prodtype
};
$.ajax({
url: "../RestService/Test/ReturnData",
type: "PUT",
contentType: 'application/json',
processData: false,
data: JSON.stringify(input),
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
},
success: function (allData) {
var mappedVersionListByProdType = $.map(allData, function (item) {
return new productVersionListByProductType(item);
});
self.editOnlyAlternativeVersions(mappedVersionListByProdType);
}
});
}
当数据从WCF服务返回时,它将以降序的方式返回数据。但我想显示在顶部选择,然后按降序对列表进行排序。我从另一项服务中获得物品清单,并从另一项服务中选择物品。是否有意义?我怎样才能实现它使用JQuery的?
你为什么使用'PUT'来获取'GET'数据? – 2013-03-04 14:00:56
在你的问题上,你可以使用一个计算属性返回一个顶部选定项目的数组。 – 2013-03-04 14:02:08
@MattBurland我用json格式发送数据。但这与问题有关吗? – DevelopmentIsMyPassion 2013-03-04 14:02:32