One feature that has been very important for us and colleagues I've spoken with is the ability to do a multi-line paste, and Smartclient's current capability in this is not great (i.e., a separate pop-up window). The reason is because users need to fill in a ListGrid and data is often coming from things like an xlsx or text file they can copy from. It's tedious and error prone to expect them to copy/paste one cell at a time.
I'd be happy for Isomorphic to vet and integrate functionality like this:
I'd be happy for Isomorphic to vet and integrate functionality like this:
Code:
pasteTextFromClipboard: function(e) { var selection = this.selection.getSelectedCells(); if (selection.length != 1) { return true; } var pastedText = undefined; if (window.clipboardData && window.clipboardData.getData) { // IE pastedText = window.clipboardData.getData('Text'); } else if (e.clipboardData && e.clipboardData.getData) { pastedText = e.clipboardData.getData('text/plain'); } else { return true; } var rowSep = null; var colSep = null; if(pastedText.indexOf(String.fromCharCode(13)) != -1){ rowSep = String.fromCharCode(13); colSep = String.fromCharCode(9); } else { rowSep = /\r?\n/; colSep = ","; } var lines = pastedText.split(rowSep); var r = selection[0][0]; var c = selection[0][1]; for(var i=0; i<lines.length; i++){ if(r >= this.getTotalRows()){ break; } var cols = lines[i].split(colSep); for(var j=0; j<cols.length; j++) { var col = c+j; var fieldName = this.getFieldName(col); if(!fieldName){ break; } this.setEditValue(r, col, cols[j]); this.validateCell(r,fieldName); } var record = this.getRecord(r); this.markRecordChanged(record); r++; } this.endEditing(); return false; }, draw: function(){ this.Super("draw", arguments); var listGrid = this; var lgDiv = this.getContentElement(); if(lgDiv == null){ console.log("lgDiv is null!"); return; } lgDiv.onpaste = function(e) { return listGrid.pasteTextFromClipboard(e); }; }
Comment