2013-06-20 49 views
0


我在頁面上有兩個Kendo ui multiselect元素從列表中選擇商店。在選擇事件我有一個函數調用,我檢查所選商店是否在另一個列表中。從Kendo UI Multiselect元素中刪除所選項目

如果選定的項目已被分配到另一個列表我提示確認。當用戶點擊確定,那麼確定,當點擊取消時,我必須從多選元素中刪除選定的項目。

這裏是我的功能:

function checkStoreSelection(e) { 

    var selectedStore = this.dataSource.view()[e.item.index()]; 
    var selectedStoreId = selectedStore.Id; 

    $.each(surveysData, function (index, surveyVal) { 
     // get each store 
     $.each(surveyVal.Stores, function (storesIndex, storesVal) { 
      // check if a store already assigned to another survey 
      if (selectedStoreId == storesVal.DBId) { 
       var answer = confirm('Some text here ... '); 
       if (answer) { 
        // nothing todo here 
       } else { 
        // have to remove the selected item 
       } 
      } 

     }); 
    }); 

}; 
+0

適合你嗎? –

回答

0

該死的傻瓜 - 答案很簡單:

e.preventDefault(); 

不世界衛生大會我需要: -/
對不起。

1

您可以從數據源中刪除項dataSource.remove(item);

檢查這個例子 http://jsfiddle.net/derickbailey/D4g8S/

+0

嘿,謝謝你,但不應該更改數據源元素,以便用戶可以像以前一樣選擇。 – chris