2016-06-28 70 views
0

我已经实现了如下拖放sap.m.list的拖放操作。现在我需要避免拖放列表中的特定项目。如何停止拖动ñ仅针对特定项目如何避免拖放sap.m.list中的特定列表项目

jQuery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-core'); 
jQuery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-widget'); 
jQuery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-mouse'); 
jQuery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-draggable'); 
jQuery.sap.require('sap.ui.thirdparty.jqueryui.jquery-ui-sortable'); 
    my.clauseRendering = function (oControl) { 
      //inject control 
      //debugger; 
      test = this; 
      test.oControl = oControl; 
     }; 
     my.clauseRendering.prototype = { 
      onAfterRendering: function() { 
       $("#clauseList-listUl").addClass('ui-sortable'); 


        $("#clauseList-listUl").sortable({ 
         //connectWith : ".ui-sortable" 
          cancel: '', 
        start: function(event, ui) { 
         debugger; 
        ui.item.startPos = ui.item.index(); 
        }, 
       // sync the model after reordering in the box 
       stop: function(event, ui) { 
        //debugger; 
       ---- 
       } 

        }).disableSelection(); 

      } 
    var ClauseList=sap.ui.getCore().byId("clauseList"); 
     ClauseList.addDelegate(new my.clauseRendering(ClauseList)); 

拖放功能这里列表中的HTML视图就像名单将采取与类“UI可排序”,使列表中的所有项目都是可拖动标签。现在我需要停止拖放该列表中的特定项目。

回答

0

可以初始化排序与取消选项:

$(".ui-sortable").sortable(
    { cancel: ".non-draggable" } 
); 

也可以稍后进行设置:

$(".ui-sortable").sortable("option", "cancel", ".non-draggable"); 

当然不是“非拖动”类,你可以使用任何选择器

0
$("#sortable1").sortable({ 
    items: "li:not(.ui-state-disabled)" 
}); 
+0

谢谢你的代码片段,它可能会提供一些有限的即时帮助。一个[正确的解释将大大提高其长期价值](/ meta.stackexchange.com/q/114762/350567)通过显示*为什么*这是一个很好的解决方案,并会使它对未来更有用有其他类似问题的读者。请[编辑]你的答案以添加一些解释,包括你所做的假设。 – iBug

相关问题