我真的很爲尋找解決方案來顯示頂部列表框中的選定項目。 我在這裏使用敲除來綁定我的列表框。該列表框在我看來將選定的項目移到列表框頂部
<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