After I edit the cells inside my selected row, when I press Esc or enter my row is saved, and then the row is still being displayed as "selected" an when I select it again it's changing to a regular row.
My problem is if I choose this 开发者_开发技巧row again it's not displayed in edit mode. It's displayed as selected, and until I choose another row, only then when I select that row again it will be in edit mode.
How can solve this, so that the saved row will be editable again when selected? (and not after editing another row before)
Ok, I think I found solution. Do you have this snippet of code in your js grid initialization? I bet that yes, becasuse it is in official jqGrid demo:
onSelectRow: function(id)
{
if(id && id !== lastsel)
{
grid.jqGrid( 'restoreRow', lastsel );
grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; } );
lastsel = id;
}
},
If yes, problem is right here. If you want to edit row, which was actually edited, you have to write it something like this:
onSelectRow: function(id)
{
if(id && id !== lastsel)
{
grid.jqGrid( 'restoreRow', lastsel );
grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; } );
lastsel = id;
}
else if(id && id === lastsel)
grid.jqGrid( 'editRow', id, true, null, function(){ grid.trigger('reloadGrid');return true; } );
or simply change if condition to only if (id) {...}
},
精彩评论