我正在尝试在表格的行上添加一个可拖动的事件,但我没有得到我应该得到的。这是一个创建表格结构的剑道网格。最后,如果可能的话,我想把这行放在不是剑道的东西上。
HTML
<div id="Assets" style="width: 200px; float: left;" data-role="grid" class="k-grid k-widget" tabindex="0">
<ul>
<div class="k-widget k-grid" id="Assets">
<div class="k-grid-header">
<div class="k-grid-header-wrap">
<table cellspacing="0">
<colgroup>
<col style="width: 240px">
</colgroup>
<tbody></tbody>
</table>
</div>
</div>
<div class="k-grid-content" style="height: 200px">
<div class="k-grid-header" style="padding-right: 17px;">
<div class="k-grid-header-wrap">
<table cellspacing="0">
<colgroup><col style="width: 240px"></colgroup>
<thead>
<tr data-role="draggable">
<th class="k-header" data-field="Id" data-title="Id" scope="col" style="display: none"><span class="k-link">Id</span></th>
<th class="k-header" data-field="Name" data-title="Name" scope="col"><span class="k-link">Name</span></th>
</tr>
</thead>
</table>
</div>
</div>
</div>
<table cellspacing="0" class="k-focusable">
<colgroup><col style="width: 240px"/></colgroup>
<tbody>
<tr data-uid="cc7fc98a-dc66-4a46-8d3a-b73d608cf32b">
<td style="display: none">1</td>
<td>A Commons</td>
</tr>
<tr class="k-alt" data-uid="daf17bf4-52d3-43a4-acc0-034c7c53e5af">
<td style="display: none">2</td>
<td>A Chase</td>
</tr>
<tr data-uid="6dbe2dec-e9ce-4640-8f61-f1ee4469a581">
<td style="display: none">4</td>
<td>Beacon</td>
</tr>
<tr class="k-alt" data-uid="569798d6-433c-4dea-b56b-5833bab22058">
<td style="display: none">5</td>
<td>Seminole</td>
</tr>
<tr data-uid="4639277c-97eb-43d0-9aa1-6402671474b5">
<td style="display: none">6</td>
<td>Commons</td>
</tr>
<tr class="k-alt" data-uid="9ad1bf14-91bf-474f-9115-246c55c38eab">
<td style="display: none">3</td>
<td>Willows</td>
</tr>
</tbody>
</table>
</ul>
</div>
JS
这是我试图选择我需要的 tr 的代码:
$(".k-focusable > tbody > tr").kendoDraggable({
hint: function(e) {
item = $('<div class="k-grid k-widget" style="background-color: lightblue; color: black;"><table><tbody><tr>' + e.html() + '</tr></tbody></table></div>');
return item;
},
});
我宁愿以纯粹的jQuery
方式做到这一点:
$("<selector>").draggable({
cursor: 'move',
distance: 40,
helper: 'clone',
opacity: 0.8,
revert: 'invalid',
revertDuration: 100,
snap: 'div.node.expanded',
snapMode: 'inner',
stack: 'div.node',
});