Skip to content

Commit

Permalink
add readOnlyMode option to Excel copy plugin and example
Browse files Browse the repository at this point in the history
  • Loading branch information
6pac committed Jan 24, 2017
1 parent ad9008b commit 6e9a019
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
17 changes: 3 additions & 14 deletions examples/example-excel-compatible-spreadsheet.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 87,6 @@ <h2>View Source:</h2>
autoEdit: false
};



var undoRedoBuffer = {
commandQueue : [],
commandCtr : 0,
Expand All @@ -100,8 98,7 @@ <h2>View Source:</h2>
},

undo : function() {
if (this.commandCtr == 0)
return;
if (this.commandCtr == 0) { return; }

this.commandCtr--;
var command = this.commandQueue[this.commandCtr];
Expand All @@ -111,8 108,7 @@ <h2>View Source:</h2>
}
},
redo : function() {
if (this.commandCtr >= this.commandQueue.length)
return;
if (this.commandCtr >= this.commandQueue.length) { return; }
var command = this.commandQueue[this.commandCtr];
this.commandCtr ;
if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) {
Expand All @@ -137,21 133,15 @@ <h2>View Source:</h2>

var pluginOptions = {
clipboardCommandHandler: function(editCommand){ undoRedoBuffer.queueAndExecuteCommand.call(undoRedoBuffer,editCommand); },
readOnlyMode : true,
includeHeaderWhenCopying : false,
newRowCreator: function(count) {

for (var i = 0; i < count; i ) {

var item = {

id: "newRow_" newRowIds

}

grid.getData().addItem(item);

}

}
};

Expand Down Expand Up @@ -198,7 188,6 @@ <h2>View Source:</h2>
grid.getCanvasNode().focus();

grid.registerPlugin(new Slick.CellExternalCopyManager(pluginOptions));


grid.onAddNewRow.subscribe(function (e, args) {
var item = args.item;
Expand Down
6 changes: 5 additions & 1 deletion plugins/slick.cellexternalcopymanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 27,7 @@
onCopyInit: optional handler to run when copy action initializes
onCopySuccess: optional handler to run when copy action is complete
newRowCreator: function to add rows to table if paste overflows bottom of table
readOnlyMode: suppresses paste
*/
var _grid;
var _self = this;
Expand Down Expand Up @@ -395,7 396,10 @@
}
}

if ((e.which === keyCodes.V && (e.ctrlKey || e.metaKey) && !e.shiftKey || (e.which === keyCodes.INSERT && e.shiftKey && !e.ctrlKey))) { // CTRL V or Shift INS
if (!_options.readOnlyMode && (
(e.which === keyCodes.V && (e.ctrlKey || e.metaKey) && !e.shiftKey)
|| (e.which === keyCodes.INSERT && e.shiftKey && !e.ctrlKey)
)) { // CTRL V or Shift INS
var ta = _createTextBox('');

setTimeout(function(){
Expand Down

0 comments on commit 6e9a019

Please sign in to comment.