Fix sorting for connectedWidth columns

This commit is contained in:
Hadi Nategh 2020-10-14 10:33:19 +02:00
parent 66c59a19f9
commit 71dabcd33b
2 changed files with 14 additions and 12 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,16 +714,16 @@ 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.sortable_recieveCallback == 'function') {
self.options.sortable_recieveCallback.call(self, event, ui); self.sortable_recieveCallback.call(self, event, ui, self.id);
} }
}, },
start: function (event, ui) { start: function (event, ui) {
if (typeof self.options.sortable_startCallback == 'function') { if (typeof self.options.sortable_startCallback == 'function') {
self.options.sortable_startCallback.call(self, event, ui); self.options.sortable_startCallback.call(self, event, ui, self.id);
} }
} }
}); });

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,20 +972,20 @@ 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
).sendRequest(); ).sendRequest();
}, },
receive: function (event, ui) { receive: function (event, ui) {
if (typeof self.options.sortable_recieveCallback == 'function') { if (typeof self.sortable_recieveCallback == 'function') {
self.options.sortable_recieveCallback.call(self, event,ui); self.sortable_recieveCallback.call(self, event, ui, self.id);
} }
}, },
start: function (event, ui) { start: function (event, ui) {
if (typeof self.options.sortable_startCallback == 'function') { if (typeof self.options.sortable_startCallback == 'function') {
self.options.sortable_startCallback.call(self, event,ui); self.options.sortable_startCallback.call(self, event, ui, self.id);
} }
} }
}); });