Get sorting between connected grids working

This commit is contained in:
Hadi Nategh 2020-09-30 16:13:53 +02:00
parent 81420b2261
commit 1f0fe84481
2 changed files with 8 additions and 6 deletions

View File

@ -688,8 +688,9 @@ var et2_grid = /** @class */ (function (_super) {
* @param {boolean|function} sortable Callback or false to disable * @param {boolean|function} sortable Callback or false to disable
*/ */
et2_grid.prototype.set_sortable = function (sortable) { et2_grid.prototype.set_sortable = function (sortable) {
var $node = jQuery(this.getDOMNode());
if (!sortable) { if (!sortable) {
this.tbody.sortable("destroy"); $node.sortable("destroy");
return; return;
} }
// Make sure rows have IDs, so sortable has something to return // Make sure rows have IDs, so sortable has something to return
@ -704,7 +705,7 @@ var et2_grid = /** @class */ (function (_super) {
}); });
var self = this; var self = this;
// Set up sortable // Set up sortable
this.tbody.sortable({ $node.sortable({
// Header does not participate in sorting // Header does not participate in sorting
items: "tr:not(.th)", items: "tr:not(.th)",
distance: 15, distance: 15,
@ -713,7 +714,7 @@ var et2_grid = /** @class */ (function (_super) {
containment: this.options.sortable_containment, containment: this.options.sortable_containment,
connectWith: this.options.sortable_connectWith, connectWith: this.options.sortable_connectWith,
update: function (event, ui) { update: function (event, ui) {
self.egw().json(sortable, [self.tbody.sortable("toArray"), self.id], null, self, true).sendRequest(); self.egw().json(sortable, [$node.sortable("toArray"), self.id], null, self, true).sendRequest();
}, },
receive: function (event, ui) { receive: function (event, ui) {
if (typeof self.options.sortable_recieveCallback == 'function') { if (typeof self.options.sortable_recieveCallback == 'function') {

View File

@ -942,9 +942,10 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
*/ */
set_sortable(sortable: boolean | Function) set_sortable(sortable: boolean | Function)
{ {
const $node = jQuery(this.getDOMNode());
if(!sortable) if(!sortable)
{ {
this.tbody.sortable("destroy"); $node.sortable("destroy");
return; return;
} }
@ -962,7 +963,7 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
const self = this; const self = this;
// Set up sortable // Set up sortable
this.tbody.sortable({ $node.sortable({
// Header does not participate in sorting // Header does not participate in sorting
items: "tr:not(.th)", items: "tr:not(.th)",
distance: 15, distance: 15,
@ -971,7 +972,7 @@ export class et2_grid extends et2_DOMWidget implements et2_IDetachedDOM, et2_IAl
containment: this.options.sortable_containment, containment: this.options.sortable_containment,
connectWith: this.options.sortable_connectWith, connectWith: this.options.sortable_connectWith,
update: function(event, ui) { update: function(event, ui) {
self.egw().json(sortable,[self.tbody.sortable("toArray"), self.id], self.egw().json(sortable,[$node.sortable("toArray"), self.id],
null, null,
self, self,
true true