作成日: 2015/08/18 最終更新日: 2015/08/18
文書種別
制限事項
詳細
SpreadJSのカスタムセル内でWijInputTextを使用して編集を行い、カスタムセルを編集中にSpreadJS外部にあるWijInputTextを選択します。このとき、SpreadJS外部にあるWijInputTextにおいて、formatオプションやmaxLengthオプションで設定した入力制御が機能しなくなります。
【再現手順】
1. サンプルを実行します。
2. カスタムセルを編集します。
3. SpreadJS外部にあるWijInputTextを選択して、"123"と入力します。
結果: 通常では英字2文字までしか入力できませんが、入力制御が機能せず、"123"と入力できてしまいます。
【サンプルコード】
<input type="text" id="textbox1" />
<div id="spread1"></div>
<script type="text/javascript">
function WijmoTextCellType() {}
WijmoTextCellType.prototype = new $.wijmo.wijspread.TextCellType();
WijmoTextCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
// WijInputTextを使用してカスタムセルを初期化します。
:
}
};
WijmoTextCellType.prototype.isImeAware = function () {
return false;
};
$(document).ready(function () {
$('#textbox1').wijinputtext({
format: 'A',
maxLength: 2
});
$('#spread1').wijspread();
var spread = $('#spread1').wijspread('spread');
var sheet = spread.getActiveSheet();
var wijmoTextCellType = new WijmoTextCellType();
sheet.getColumn(1).cellType(wijmoTextCellType);
});
</script>
【再現手順】
1. サンプルを実行します。
2. カスタムセルを編集します。
3. SpreadJS外部にあるWijInputTextを選択して、"123"と入力します。
結果: 通常では英字2文字までしか入力できませんが、入力制御が機能せず、"123"と入力できてしまいます。
【サンプルコード】
<input type="text" id="textbox1" />
<div id="spread1"></div>
<script type="text/javascript">
function WijmoTextCellType() {}
WijmoTextCellType.prototype = new $.wijmo.wijspread.TextCellType();
WijmoTextCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
// WijInputTextを使用してカスタムセルを初期化します。
:
}
};
WijmoTextCellType.prototype.isImeAware = function () {
return false;
};
$(document).ready(function () {
$('#textbox1').wijinputtext({
format: 'A',
maxLength: 2
});
$('#spread1').wijspread();
var spread = $('#spread1').wijspread('spread');
var sheet = spread.getActiveSheet();
var wijmoTextCellType = new WijmoTextCellType();
sheet.getColumn(1).cellType(wijmoTextCellType);
});
</script>
回避方法
この現象は制限事項です。WijInputTextのマウスダウン処理が競合することにより発生しており、WijInputText側で対応することができません。
下記のように、SpreadJS外部のWijInputTextのマウスダウンイベントでfocusメソッドを実行することで、本現象を回避することができます。
【サンプルコード】
$("#textbox1").bind("mousedown", function () {
setTimeout(function () {
$("#textbox1").wijinputtext("focus");
}, 0);
})
下記のように、SpreadJS外部のWijInputTextのマウスダウンイベントでfocusメソッドを実行することで、本現象を回避することができます。
【サンプルコード】
$("#textbox1").bind("mousedown", function () {
setTimeout(function () {
$("#textbox1").wijinputtext("focus");
}, 0);
})
旧文書番号
81431