結合セルに入力したデータが正しく表示されない
対象製品
SpreadJS 9J
発生環境
9.20171.0
状況
回避方法あり
詳細
データ連結を用いたデータ表示時において、結合セルに入力したデータが正しく表示されない現象が発生します。
【再現手順】
1.以下の再現コードを実行します
2.A3セルに"x"を入力し、Enterキーを押下します
3.A3セルに"y"を入力し、Enterキーを押下します
【動作結果】
"y"の入力にも関わらず、再現手順2.で入力した"x"がA3セルに表示されます。
【再現コード】
window.onload = function() {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var sheet = spread.getActiveSheet();
//連結データソースを生成します
var source = [];
var maxCount = 5;
for (var i = 0; i < 5; i++) {
var data = { text1:(i + 1), text2:(i + 1), text3:(i + 1), text4:(i + 1)};
source.push(data);
}
// 描画処理を一時停止します
sheet.suspendPaint();
// データソースを設定します
sheet.setDataSource(source);
// セルを結合します
sheet.addSpan(2, 0, 3, 1);
// 描画処理を再開します
sheet.resumePaint();
};
【再現手順】
1.以下の再現コードを実行します
2.A3セルに"x"を入力し、Enterキーを押下します
3.A3セルに"y"を入力し、Enterキーを押下します
【動作結果】
"y"の入力にも関わらず、再現手順2.で入力した"x"がA3セルに表示されます。
【再現コード】
window.onload = function() {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var sheet = spread.getActiveSheet();
//連結データソースを生成します
var source = [];
var maxCount = 5;
for (var i = 0; i < 5; i++) {
var data = { text1:(i + 1), text2:(i + 1), text3:(i + 1), text4:(i + 1)};
source.push(data);
}
// 描画処理を一時停止します
sheet.suspendPaint();
// データソースを設定します
sheet.setDataSource(source);
// セルを結合します
sheet.addSpan(2, 0, 3, 1);
// 描画処理を再開します
sheet.resumePaint();
};
回避方法
以下の回避コードを使用して現象の回避が可能です。
【回避コード】
------------------------------------
var oldMoveDown = GC.Spread.Sheets.Commands.commitInputNavigationDown.execute;
GC.Spread.Sheets.Commands.commitInputNavigationDown.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
var activeRow = sheet.getActiveRowIndex();
var activeCol = sheet.getActiveColumnIndex();
var rowCount = sheet.getRowCount();
var currentSpan = sheet.getSpan(activeRow, activeCol)
if (currentSpan && (currentSpan.row + currentSpan.rowCount >= rowCount)) {
sheet.endEdit();
return true;
} else {
return oldMoveDown.apply(this, arguments);
}
}
------------------------------------
【現象再現コードへの回避コード適用例】
------------------------------------
var oldMoveDown = GC.Spread.Sheets.Commands.commitInputNavigationDown.execute;
GC.Spread.Sheets.Commands.commitInputNavigationDown.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
var activeRow = sheet.getActiveRowIndex();
var activeCol = sheet.getActiveColumnIndex();
var rowCount = sheet.getRowCount();
var currentSpan = sheet.getSpan(activeRow, activeCol)
if (currentSpan && (currentSpan.row + currentSpan.rowCount >= rowCount)) {
sheet.endEdit();
return true;
} else {
return oldMoveDown.apply(this, arguments);
}
}
window.onload = function() {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var sheet = spread.getActiveSheet();
//連結データソースを生成します
var source = [];
var maxCount = 5;
for (var i = 0; i < 5; i++) {
var data = { text1:(i + 1), text2:(i + 1), text3:(i + 1), text4:(i + 1)};
source.push(data);
}
// 描画処理を一時停止します
sheet.suspendPaint();
// データソースを設定します
sheet.setDataSource(source);
// セルを結合します
sheet.addSpan(2, 0, 3, 1);
// 描画処理を再開します
sheet.resumePaint();
};
------------------------------------
【回避コード】
------------------------------------
var oldMoveDown = GC.Spread.Sheets.Commands.commitInputNavigationDown.execute;
GC.Spread.Sheets.Commands.commitInputNavigationDown.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
var activeRow = sheet.getActiveRowIndex();
var activeCol = sheet.getActiveColumnIndex();
var rowCount = sheet.getRowCount();
var currentSpan = sheet.getSpan(activeRow, activeCol)
if (currentSpan && (currentSpan.row + currentSpan.rowCount >= rowCount)) {
sheet.endEdit();
return true;
} else {
return oldMoveDown.apply(this, arguments);
}
}
------------------------------------
【現象再現コードへの回避コード適用例】
------------------------------------
var oldMoveDown = GC.Spread.Sheets.Commands.commitInputNavigationDown.execute;
GC.Spread.Sheets.Commands.commitInputNavigationDown.execute = function (context, options) {
var sheet = context.getSheetFromName(options.sheetName);
var activeRow = sheet.getActiveRowIndex();
var activeCol = sheet.getActiveColumnIndex();
var rowCount = sheet.getRowCount();
var currentSpan = sheet.getSpan(activeRow, activeCol)
if (currentSpan && (currentSpan.row + currentSpan.rowCount >= rowCount)) {
sheet.endEdit();
return true;
} else {
return oldMoveDown.apply(this, arguments);
}
}
window.onload = function() {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
var sheet = spread.getActiveSheet();
//連結データソースを生成します
var source = [];
var maxCount = 5;
for (var i = 0; i < 5; i++) {
var data = { text1:(i + 1), text2:(i + 1), text3:(i + 1), text4:(i + 1)};
source.push(data);
}
// 描画処理を一時停止します
sheet.suspendPaint();
// データソースを設定します
sheet.setDataSource(source);
// セルを結合します
sheet.addSpan(2, 0, 3, 1);
// 描画処理を再開します
sheet.resumePaint();
};
------------------------------------