2013-06-20 47 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