Skip to content

Commit

Permalink
dev Minor improvements to table editor
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Dec 17, 2015
1 parent 371f3e0 commit c9c1a51
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions protected/views/labels/update.php
Expand Up @@ -67,18 +67,6 @@ function isEmptyRow(instance, row) {

function defaultValueRenderer(instance, td, row, col, prop, value, cellProperties) {
var args = arguments;
if (args[5] === null && isEmptyRow(instance, row)) {
if (col === 0) {
args[5] = 'A' + (row + 1);
} else {
args[5] = tpl[col];
}
td.style.color = '#999';
}
else {
td.style.color = '';
}

if (cellProperties.readOnly === true) {
td.style.setProperty('background-color','#eee', 'important');
td.style.setProperty('pointer-events','none');
Expand All @@ -94,6 +82,39 @@ function defaultValueRenderer(instance, td, row, col, prop, value, cellPropertie
}
});
hot1 = new Handsontable(container, {
beforeAutofill: function(start, end, data) {
// Check how many rows.
if (start.col === 0) {

var pattern = data.slice();
data.length = 0;
for (var i = start.row; i <= end.row; i++) {

var template = pattern[(i - start.row) % (pattern.length)].slice();
template[0] = 'A' + (i + 1);
//
// for (var j = 1; j < template.length; j++) {
// // Check other columns.
// if (pattern.length > 1 && i > start.row
// && typeof prev != 'undefined'
// && !isNaN(template[j])
// && !isNaN(prev[j])
// ) {
// template[j] += template[j] - prev[j];
// }
// }
// var prev = pattern[(i - start.row) % (pattern.length)].slice();
data.push(template);

}
return data;
}



// if e
// debugger;
},
minSpareRows: 1,
contextMenu: true,
startCols: <?=count($model->getLanguageArray()) + 3; ?>,
Expand Down Expand Up @@ -218,7 +239,6 @@ function createColumns() {


});
console.log(result);
return result;
}

Expand Down Expand Up @@ -253,6 +273,7 @@ function createDropdown() {
}
});
}
hot1.deselectCell();
});

$('#labels').on('change', 'select', function() {
Expand Down

0 comments on commit c9c1a51

Please sign in to comment.