This javascript ALMOST works in GRID-EDIT modehttps://jsfiddle.net/okjb7ykd/1/I select 6 rows of COLUMN B
Then paste into GRID-EDIT
then it pastes 3 rows of my initial selectionNOTICE it only pastes 3 rows, where did the other 3 rows go?It skips every odd row when used with PHPMaker grid-edit html table form. (Normal HTML table form inputs works fine as it works in the jsfiddle demo)EXAMPLE:
In Excel I highlight select cells B1,B2,B3,B4,B5,B6
Press Ctrl-C
Next go to browser and focus the Grid-Edit field where I want to start to paste
Press Ctrl-V
Only B1,B3,B5 are successfully pasted into Grid-Edit.Can any of the masters figure how to fix the javascript code pasting data from Excel into PHPMaker Grid-Edit? Thanks!
think I found the problem…the original javascript counts every TR rowin phpmaker generated files, between each TR there is: EXAMPLE from generated php (grid-edit):
...
...
...
...
...
...
if I select excel cells: B1,B2,B3,B4,B5,B6go back to browser to pasteit pastes B1,B3,B5BUT if I delete all: in the inspector and paste
it successfully pastes all 6: B1,B2,B3,B4,B5,B6 in 6 rowsIs there a way to skip
from its counting in the jquery code?I suspect it is the line: row.children().eq(col).find('input').val(values[i]);
that needs to filter out the "" from the TR row counting.
$(document).ready(function() {
$('td input').bind('paste', null, function(e) {
$input = $(this);
setTimeout(function() {
var values = $input.val().split(/\s+/),
row = $input.closest('tr'),
col = $input.closest('td').index();
for (var i = 0; i < values.length; i++) {
row.children().eq(col).find('input').val(values[i]);
row = row.next();
}
}, 0);
});
});
I think the problem is data-rowindexthere is double data-rowindex, once in the and second time in which is why 6 copied row cells only pastes 3 rowsIs it safe to remove all the tags in the grid-edit table body if I don’t use AJAX?