Skip to content

Commit

Permalink
fixed small column reordering bug
Browse files Browse the repository at this point in the history
  • Loading branch information
stevewirts committed Feb 17, 2015
1 parent c301fbe commit 651ef70
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 26 deletions.
3 changes: 3 additions & 0 deletions behaviors/fin-hypergrid-behavior-default.html
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@
//return true to close the editor
//anything else will leave the editor open
return true;
},
endDragColumnNotification: function() {
console.log('end drag column notification');
}

});
Expand Down
48 changes: 25 additions & 23 deletions behaviors/fin-hypergrid-behavior-qtree.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
this.reconnect();
this.msgCounter = Date.now();
this.msgResponsesActions = {};
},

},
getFixedRowCount: function() {
return 2;
},
Expand Down Expand Up @@ -490,18 +491,17 @@
}
return id;
},
swapColumns: function(src, tar) {
endDragColumnNotification: function() {
var self = this;
var tmp = this.columnIndexes[src];
this.columnIndexes[src] = this.columnIndexes[tar];
this.columnIndexes[tar] = tmp;

var visible = this.block.F.slice(0);
var t = visible[src];
visible[src] = visible[tar];
visible[tar] = t;
var msgId = this.getNextMessageId(function() {
for (var i = 0; i < visible.length; i++) {
visible[i] = this.getColumnId(i);
}
var msgId = this.getNextMessageId(function(message) {
//ignore any predecessor column swap results if a new one has been posted
self.initColumnIndexes();
self.handleMessage(message);
});
var changeCols = {
id: msgId,
Expand All @@ -523,11 +523,23 @@
style.height = '90%';
style.whiteSpace = 'nowrap';
},
handleMessage: function(d) {
this.block = d;

if (d.rows !== this.block.N - 1) {
if (this.sizeChanged) {
this.sizeChanged();
}
}
if (!this.columnIndexes || this.columnIndexes.length === 0) {
this.initColumnIndexes();
}
this.changed();
},
//websocket connection to Q. try and do a reconnect after 2 seconds if we fail
connect: function() {
var d = {};
var self = this;
var oldSize = 0;
if ('WebSocket' in window) {
try {
this.ws = new WebSocket(this.url);
Expand All @@ -554,25 +566,15 @@
};
this.ws.onmessage = function(e) {
d = JSON.parse(e.data);
self.block = d;
var msgId = d.id;
var action = self.msgResponsesActions[msgId];
if (action) {
action(d);
self.msgResponsesActions[id] = "done";
self.msgResponsesActions[msgId] = undefined;
} else {
self.handleMessage(d);
}
oldSize = self.block.N - 1;

if (d.rows !== oldSize) {
if (self.sizeChanged) {
self.sizeChanged();
}
}
if (!self.columnIndexes || self.columnIndexes.length === 0) {
self.initColumnIndexes();
}
self.changed();
//console.dir(self.block);
};
this.ws.onerror = function(e) {
self.clearData();
Expand Down
1 change: 1 addition & 0 deletions features/fin-hypergrid-feature-column-moving.html
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@
grid.repaint();
requestAnimationFrame(function() {
d.style.display = 'none';
grid.getBehavior().endDragColumnNotification();
});
}, columnAnimationTime + 50);

Expand Down
2 changes: 1 addition & 1 deletion fin-hypergrid-renderer.html
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
for (var r = 0; r < numRows; r++) {

var height = this.getFixedRowHeight(r);
var align = behavior.getFixedRowAlignment(c, r);
var align = behavior.getFixedRowAlignment(c + scrollLeft, r);
var value = behavior.getFixedRowValue(c + scrollLeft, r);

//translatedX allows us to reorder columns
Expand Down
2 changes: 1 addition & 1 deletion fin-hypergrid.min.html

Large diffs are not rendered by default.

Binary file modified q/s3.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion q/s3/w.q
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ W:0Ni

.js.exe:{.js[x`fn]x}
.js.set:{`Z set .tt.cons[T;P;A;S;G]F;.js.ret x}
.js.obj:{`Z`G`H`F`I`Q`S`R`N!(Z;G;H;F;I;Q;S;R;N)}
.js.obj:{{x!get each x}`Z`G`H`F`I`Q`S`R`N}
.js.ret:{x,.js.obj[]}
.js.upd:{if[not null W;neg[W](`.js.exe;.js.set()!())]}
.js.ups:{if[not null W;`Z set 0!(`n_ xkey Z)upsert`n_ xkey .tt.cons[T;P;A;S;G]x;neg[W](`.js.exe;.js.ret()!())]}

0 comments on commit 651ef70

Please sign in to comment.