我有一个使用igGrid版本16.2的IgniteUI。
我试图使用jQuery UI版本1.11.4中的" draggable“库(与jQuery版本1.11.3相结合)使行可拖动。
我的“可下垂”目标是igGrid之外的div。
只要我保持在网格中,我就可以拖放行。但是,一旦我试图将行拖出网格,网格就开始滚动。
下面是我的jQuery,它将行转换为“可拖动”元素:
$("#grid > tbody > tr").draggable({
helper: "clone",
revert: "invalid",
cursorAt: { bottom: 0, left: 0 },
start: function (evt, ui) {
// get the id of the row being dragged
var row_id = ui.helper.prevObject.data("id");
// get a reference to the <tr> being dragged
var original_row_element = $("#grid > tbody > tr[data-id='" + row_id + "']");
// get the collection of all <tr>'s that come after the selected row
var all_rows_after_the_original = original_row_element.nextAll("tr");
// move all those rows to a temporary holding <div> outside of the grid
$("#temp_row_holder").append(all_rows_after_the_original);
},
stop: function (evt, ui) {
// get all those rows that we moved out of the grid earlier
var all_rows_after_the_original = $("#temp_row_holder").children("tr");
// move the <tr>'s back into the grid
$("#grid > tbody").append(all_rows_after_the_original);
}
});下面是我的网格中可滚动的部分,一旦它被Infragistics库呈现出来了:
<div id="grid_scroll" class="ui-iggrid-scrolldiv ui-widget-content igscroll-touchscrollable" data-scroll="true" data-onedirection="true" data-xscroller="#grid_hscroller" style="overflow-x: hidden; overflow-y: auto; height: 311px;">
<table id="grid" role="grid" aria-describedby="grid_scroll" cellpadding="0" cellspacing="0" border="0" class="ui-iggrid-table ui-widget-content" style="table-layout: fixed;">
<colgroup></colgroup>
<tbody role="rowgroup" class="ui-widget-content ui-iggrid-tablebody ui-ig-record ui-iggrid-record">
<tr data-id="c3bf5936-8786-e711-8135-caf5c8230062" role="row" tabindex="0" class="open-hand-pointer ui-draggable ui-draggable-handle"></tr>
<tr class="ui-ig-altrecord ui-iggrid-altrecord open-hand-pointer ui-draggable ui-draggable-handle" data-id="a2a54d20-5a83-e711-8135-caf5c8230062" role="row" tabindex="0"></tr>
<tr data-id="ca784490-cb82-e711-8135-caf5c8230062" role="row" tabindex="0" class="open-hand-pointer ui-draggable ui-draggable-handle"></tr>
<tr class="ui-ig-altrecord ui-iggrid-altrecord open-hand-pointer ui-draggable ui-draggable-handle" data-id="4d95ba39-cd81-e711-8135-caf5c8230062" role="row" tabindex="0"></tr>
<tr data-id="7b02f501-cb81-e711-8135-caf5c8230062" role="row" tabindex="0" class="open-hand-pointer ui-draggable ui-draggable-handle"></tr>
</tbody>
</table>
</div>正如您所看到的,我目前的解决方案是从网格中删除所有同级<tr>,这样当我拖动行时它就不会滚动。这个解决方案工作得很好,但是从最终用户的角度来看,它显然是不可接受的,因为它们的所有行在它们开始拖动时突然消失。
似乎有一些CSS或javascript可以修改"start“事件上的网格,以防止其滚动。我也尝试过摆弄overflow-y属性,因为对我的CSS无知的大脑来说,这似乎是显而易见的答案,但没有任何帮助。
编辑:根据请求, 这里是一个JS
https://stackoverflow.com/questions/46531802
复制相似问题