Jquery 如何设置标记为不可拖动和/或不可拖放的单个行?

Jquery 如何设置标记为不可拖动和/或不可拖放的单个行?,jquery,asp.net-mvc-3,Jquery,Asp.net Mvc 3,我在我的asp.NETMVC3应用程序中使用jquery可拖动插件,用户可以在其中拖放一行表格 我的要求是,我需要将表中的一些行标记为不可拖动和/或不可拖放(这样其他行就不能拖放到它们上) 有人能指导我如何实现这一点吗 注:我在网上看到的一个选项是“TableDnD插件” 还有别的办法吗。有人能给我一些代码吗???JQUERY UI可拖放部分 这个问题被问得很频繁,所以我作了回答 看 编辑更新: 我把它弄得很漂亮 HTML 还有一些css table{ width:200px; border:

我在我的asp.NETMVC3应用程序中使用jquery可拖动插件,用户可以在其中拖放一行表格

我的要求是,我需要将表中的一些行标记为不可拖动和/或不可拖放(这样其他行就不能拖放到它们上)

有人能指导我如何实现这一点吗

注:我在网上看到的一个选项是“TableDnD插件”


还有别的办法吗。有人能给我一些代码吗???

JQUERY UI可拖放部分

这个问题被问得很频繁,所以我作了回答

看 编辑更新:

我把它弄得很漂亮 HTML

还有一些css

table{ width:200px;  border: brown 1px solid; padding:5px;}
table tr {background-color:#FCF6CF;}
table tr:hover:not(.disabled) {background-color:#ECF1EF;}
tr:not(.disabled){cursor:pointer;}
tr.disabled{background-color:#FEE0C6; cursor:not-allowed;}
MVC3相关章节

要在mvc3中执行类似的操作,可以使用viewmodel项中的foreach循环填充表,即

<table id="@Model.Table1.Name">
@{ foreach(var item in Model.Table1.Items){
     <tr><td> @Model.Table1.RowText </tr></td>  
 }}
</table>

您是否可以共享该表的html和可拖动/可拖放定义,以及如何识别不可拖动的trsadd a class.disabled到已禁用的元素,然后在未标记该类的行上使用可拖动的。参见我的答案和示例JSIDLE在
表2
之后缺少
tr:not(.disabled)
,因此第9行仍然可以拖动。
table{ width:200px;  border: brown 1px solid; padding:5px;}
table tr {background-color:#FCF6CF;}
table tr:hover:not(.disabled) {background-color:#ECF1EF;}
tr:not(.disabled){cursor:pointer;}
tr.disabled{background-color:#FEE0C6; cursor:not-allowed;}
<table id="@Model.Table1.Name">
@{ foreach(var item in Model.Table1.Items){
     <tr><td> @Model.Table1.RowText </tr></td>  
 }}
</table>
public class MyTable{
    public List<String> RowText {get;set;}
    public string Name {get;set;}
}
public class MyViewModel{
   public MyTable Table1{get;set;}
   public MyTable Table2{get;set;}

   //and it would also include the properties for other elements on the page too
}