2016-06-28 17 views
0

私は以下のようにsap.m.listに対してドラッグアンドドロップを実装しました。今私は、リストの特定の項目のドロップを避ける必要があります。ドラッグを止めるnは、特定のアイテム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

関連する問題