vitmalina / w2ui

UI widgets for modern apps. Data table, forms, toolbars, sidebar, tabs, tooltips, popups. All under 120kb (gzipped).
http://w2ui.com
MIT License
2.66k stars 730 forks source link

Reorder rows issue #635

Open vitmalina opened 10 years ago

vitmalina commented 10 years ago

I have discovered a minor problem when using "reorderRows: true" alongside "multiSelect: false". In the function mouseStart you check if multiSelect is set in the else part of "if (event.altKey)". In this case the mouseMove event is never registered. I believe this test has to be extended to check reorderRows and multiSelect.

davidlward commented 9 years ago

I think that I've worked around this. Comment out line 4949 //$('#grid_'+ obj.name + '_ghost').remove();

davidlward commented 9 years ago

After spending some more time with it, this appears to be the proper fix: After line 4944, add a condition around the next 6 lines:

if (ind1 != null) {
    var tmp = obj.records[ind1];
    obj.records.splice(ind1, 1);
    var ind2 = obj.get(mv.to, true);
    if (ind1 > ind2) obj.records.splice(ind2, 0, tmp); else obj.records.splice(ind2+1, 0, tmp);
    $('#grid_'+ obj.name + '_ghost').remove();
    obj.refresh();
}
vitmalina commented 9 years ago

I cannot find where the lines should be inserted. I do not edit w2ui.js file directly, but concatenate it with grunt from sources in /src folder. I tried to look up where it could be, but cannot find it. Please submit a pull request.

WolfgangVonL commented 9 years ago

Thanks davidlward. Your trick works fine when reorderRows is true and multiSelect is false. However when multiSelect is true, no way to reorder the rows: only the first selected row is moved and the others stay at the same place and they are still selected.

Do you have an idea of where the problem may come?