グリッド内の重複する番号をチェックするグリッドがあります。これは成功しましたが、プログラムが重複したバーコードをチェックした後、行を復元し、ユーザーが正しいバーコードを再入力できるようにもう一度編集しようとしましたが、今回は編集メソッドでキー入力イベントが発生しません
私が得たものを再現する手順は以下のとおりです
こちらのコードをご覧ください。どのようなエラーが発生したかを確認するには、最初の行に数字を入力し (最初の列はグリッドでのみ編集可能)、2 番目の行に同じ数字を入力すると、バーコードが重複しているというエラーが表示されるので、ユーザーに数字を変更してもらいたいのですが、この時点で editMethod を起動しませんか? 助けてください
コード:
var portalBarcodeGrid = namespace.extend(com,'com.barcodeGrid');
portalBarcodeGrid = {
/*requestInfo : {
reOpenMode : true,
NextApplicableStep : 'SHIP_LOAN',
RequestNumber : 'PAT_10000165',
LoanTrackingInfo : [
{LocalNumber : 'LON1', LoanStatusComplete : true },
{LocalNumber : 'LON2', LoanStatusComplete : true },
{LocalNumber : 'LON3', LoanStatusComplete : true },
{LocalNumber : 'LON4', LoanStatusComplete : true },
{LocalNumber : 'LON5', LoanStatusComplete : true },
]
},*/
requestInfo : {
NextApplicableStep : 'SHIP_LOAN',
RequestNumber : 'PAT_10000165',
LoanTrackingInfo : [
]
},
requestProcessStatus : {
LoanTrackingInfo : [
//{LocalNumber : '', ProcessStatus : ''}
]
},
processStatus : {
PENDING : 'Pending',
PROCESSING : 'Processing',
PROCESSSUCCESS : 'Process Success',
PROCESSFAILED : 'Process Failed',
UNDOSUCCESS : 'Undo Success',
UNDOFAILED : 'Undo Failed'
},
initializeBarcodeGrid : function( gridSelector ) {
$(gridSelector).jqGrid({
datatype : "local",
width : 'auto',
height : 'auto',
gridview : true,
shrinkToFit : true,
colNames : [ 'Barcode', 'Status' ],
colModel : [ {name : 'LocalNumber',resizable : false,sortable : false, editoptions: { maxlength: 15 }},
{name : 'ProcessStatus',resizable : false,sortable : false},
],
onSelectRow : function(rowId, status, e) {
portalBarcodeGrid.onBarcodeGridSelectRow( gridSelector, rowId );
},
editurl: 'clientArray',
});
// apply height and width rules to parent of the grid
$(gridSelector).parents('div.ui-jqgrid-bdiv').css("max-height","120px");
$(gridSelector).parents('div.ui-jqgrid-bdiv').css("max-width","480px");
$(gridSelector).parents('div.ui-jqgrid-bdiv').css("overflow-x","hidden");
},
selectBarcodeGridRow : function ( rowId ) {
console.log(" selectBarcodeGridRow ");
var gridSelector = '#'+ portalBarcodeGrid.getGridSelectorId( rowId );
$( gridSelector ).jqGrid( "setSelection", rowId, true );
},
getGridSelectorId : function ( rowId ){
return $( '#' +rowId ).closest( 'table' ).attr( 'id' );
},
onBarcodeGridSelectRow : function ( gridSelector, rowId ) {
console.log(" onBarcodeGridSelectRow ");
var currentRowNum = rowId.split('-')[1];
var editableRowId = $( gridSelector ).find( ':input' ).parent().parent().attr( 'id' );
var editableRowNum = 0;
if(editableRowId)
editableRowNum = editableRowId.split( '-' )[ 1 ];
if( editableRowId && editableRowId != rowId ){
//portalBarcodeGrid.selectBarcodeGridRow( gridSelector, editableRowId );
$( gridSelector ).jqGrid( 'saveRow', editableRowId, '', '', '', portalBarcodeGrid.getRowData );
//portalBarcodeGrid.selectBarcodeGridRow( gridSelector, rowId );
var prevTdText = $.trim( $( '#'+editableRowId ).find( 'td:first' ).text() );
if(prevTdText.length > 0 && ++editableRowNum == currentRowNum ){
var gridDataObj = $( gridSelector ).jqGrid( 'getRowData', rowId );
if(gridDataObj && gridDataObj.ProcessStatus == portalBarcodeGrid.processStatus.PROCESSSUCCESS)
$( gridSelector ).jqGrid( 'editRow', rowId, true, portalBarcodeGrid.addRows( rowId ), '', '', '' , portalBarcodeGrid.getRowData );
}
return;
}
else{
var gridDataObj = $( gridSelector ).jqGrid( 'getRowData', rowId );
if( gridDataObj.ProcessStatus != portalBarcodeGrid.processStatus.PROCESSSUCCESS && ( portalBarcodeGrid.requestInfo.NextApplicableStep == 'SHIP_LOAN' || portalBarcodeGrid.requestInfo.NextApplicableStep == 'RECEIVE_LOAN' ) ){
portalBarcodeGrid.addEditableProperty( gridSelector, rowId );
}
else{
portalBarcodeGrid.putValueInTextBox( '#txtBarcode',gridDataObj.LocalNumber );
}
}
},
putValueInTextBox : function( selector,barcode ) {
$( selector ).val( barcode );
},
addInitialGridRecord : function ( gridSelector ) {
if( portalBarcodeGrid.requestInfo.reOpenMode == true ){
portalBarcodeGrid.createBarcodeGridRows( gridSelector, portalBarcodeGrid.requestInfo.LoanTrackingInfo);
}
else if( portalBarcodeGrid.requestInfo.NextApplicableStep == 'SHIP_LOAN' || portalBarcodeGrid.requestInfo.NextApplicableStep == 'RECEIVE_LOAN' ){
portalBarcodeGrid.createBarcodeGridEmptyRows( gridSelector,6 )
}
else if( portalBarcodeGrid.requestInfo.NextApplicableStep == 'RETURN_LOAN' || portalBarcodeGrid.requestInfo.NextApplicableStep == 'COMPLETE_LOAN' ){
portalBarcodeGrid.createBarcodeGridRows( gridSelector, portalBarcodeGrid.requestInfo.LoanTrackingInfo );
}
},
createBarcodeGridEmptyRows : function( gridSelector,noOfRows ) {
var gridId = gridSelector.split('#')[1];
for( var i = 0; i < noOfRows; i++ ){
var obj = {};
obj.LocalNumber = '';
if( i == 0 )
obj.ProcessStatus = portalBarcodeGrid.processStatus.PENDING;
else
obj.Status = '';
portalBarcodeGrid.requestProcessStatus.LoanTrackingInfo.push( obj );
$( gridSelector ).jqGrid( 'addRowData', gridId+'_tr-'+(i+1), obj );
}
// select first row of the grid
var rowId = $( gridSelector ).getDataIDs()[0];
portalBarcodeGrid.selectBarcodeGridRow( rowId );
},
createBarcodeGridRows : function( gridSelector, loanTrackingInfo ) {
var loanTrackingCount = loanTrackingInfo == undefined || loanTrackingInfo.length == 0 ? 1 : loanTrackingInfo.length;
var numOfRows = Math.ceil((loanTrackingCount + 1) / 6 ) * 6;
var lastDataRowId = 0;
portalBarcodeGrid.createBarcodeGridEmptyRows(gridSelector, numOfRows);
var arrayRef = loanTrackingInfo;
var gridId = gridSelector.split('#')[1];
var getArrDataId = $( gridSelector ).jqGrid( 'getDataIDs' );
for( var i = 0; i < arrayRef.length; i++ ){
$( gridSelector ).jqGrid( 'setCell', getArrDataId[i], 'LocalNumber', arrayRef[i].LocalNumber );
if(arrayRef[i].LoanStatusComplete)
$( gridSelector ).jqGrid( 'setCell', getArrDataId[i], 'ProcessStatus', portalBarcodeGrid.processStatus.PROCESSSUCCESS );
else
$( gridSelector ).jqGrid( 'setCell', getArrDataId[i], 'ProcessStatus', portalBarcodeGrid.processStatus.PENDING );
lastDataRowId = getArrDataId[i];
}
if(portalBarcodeGrid.requestInfo.reOpenMode){
portalBarcodeGrid.addPendingMsg( gridSelector, gridId, lastDataRowId );
}
},
addPendingMsg : function( gridSelector, gridIdToAppendToRowId, lastDataRowId ) {
var pendingRowNum = lastDataRowId.split( '-' )[ 1 ];
portalBarcodeGrid.addPendingRow( gridSelector, gridIdToAppendToRowId+'_tr-'+(++pendingRowNum) );
},
addPendingRow : function ( gridSelector,rowId ) {
portalBarcodeGrid.selectBarcodeGridRow( rowId );
$( gridSelector ).jqGrid( 'setCell', rowId, 'ProcessStatus', portalBarcodeGrid.processStatus.PENDING );
},
addEditableProperty : function( gridSelector,rowId ){
console.log(" addEditableProperty ");
var prevTdText = $.trim( $( '#'+rowId ).prev('tr').find('td:first').text() );
var rowNum = rowId.split( '-' )[ 1 ];
if( rowNum == 1 ) {
$(gridSelector).jqGrid( 'setColProp', 'LocalNumber', { editable : true } );
$( gridSelector ).jqGrid( 'editRow', rowId, true, '', '', '', '', portalBarcodeGrid.getRowData );
}
if( rowNum > 1 ) {
if( prevTdText.length < 1 ){
$( gridSelector ).jqGrid( 'setColProp', 'LocalNumber', { editable : false } );
}
else{
$( gridSelector ).jqGrid( 'setColProp', 'LocalNumber', { editable : true } );
$( gridSelector ).jqGrid( 'editRow', rowId, true, portalBarcodeGrid.addRows( rowId ), '', '', '' , portalBarcodeGrid.getRowData );
}
}
},
addRows : function( rowId ) {
console.log(" addRows ");
var gridSelector = '#'+ portalBarcodeGrid.getGridSelectorId( rowId );
var gridId = gridSelector.split( '#' )[ 1 ];
var lastrowid = $( gridSelector ).jqGrid( 'getDataIDs' ).pop();
var prevTD = $.trim( $( '#'+rowId ).prev( 'tr' ).find( 'td:first' ).text());
if ( rowId == lastrowid ) {
if( prevTD.length > 1 ) {
var rowId = lastrowid.split('-')[1];
for ( var i = 0; i < 6; i++) {
var obj = {};
var addRow = $( gridSelector ).jqGrid( 'addRowData', gridId+'_tr-'+(++rowId),obj );
}
}
}
},
getRowData : function( rowId,result ) {
console.log(" getRowData ");
var gridSelector = '#'+ portalBarcodeGrid.getGridSelectorId( rowId );
var gridDataObj = $( gridSelector ).jqGrid( 'getRowData', rowId );
if( $.trim(gridDataObj.LocalNumber) != 0 ){
var barcodeDuplicate = portalBarcodeGrid.getDuplicateBarcode( gridSelector, rowId, gridDataObj );
if( !barcodeDuplicate ) {
$( gridSelector ).jqGrid( 'setCell', rowId, 'ProcessStatus', portalBarcodeGrid.processStatus.PROCESSSUCCESS );
var rowNum = rowId.split('-')[1];
var nextTrId = $( '#'+rowId ).next( 'tr' ).attr( 'id' );
//get the next row in grid and put focus onto it
portalBarcodeGrid.selectBarcodeGridRow( nextTrId );
}
else {
$( '#'+rowId ).find( ':input' ).select();
$(gridSelector).jqGrid( 'restoreRow', rowId ,true );
portalBarcodeGrid.selectBarcodeGridRow( rowId );
}
}
else{
//$('#divError').text("Please enter a Barcode");
$( gridSelector ).jqGrid( 'restoreRow', rowId, true );
}
},
getDuplicateBarcode : function ( gridSelector, rowId) {
console.log(" getDuplicateBarcode ");
var barcodeDuplicate = false ;
var currentRowData = $( gridSelector ).jqGrid( 'getRowData', rowId );
var gridRows = $( gridSelector ).find( 'tr' );
for( var i = 0; i < gridRows.length; i++){
gridRowId = $ (gridRows [i]).attr( 'id' );
if ( currentRowData.LocalNumber == $( gridRows[i] ).find( 'td:first' ).text() && rowId != gridRowId ) {
$('#divError').text("Duplicate Barcode");
barcodeDuplicate = true;
}
}
return barcodeDuplicate;
},
};