Support Article
Hitting enter in an editable repeating grid creates a new row
SA-9453
Summary
In section we have repeating grid for reserve, when we select a row of a particular accountline to update reserve, and hit 'enter' key ,a new row is added by default, which is OOTB functionality. No row should be added on hitting enter key.
Error Messages
No message just a row is added on screen.
Resolution
This issue is resolved through the following local change:
Use the below code in a non-autogenerated section and include the same at the end of section containing the repeat grid.
<script>
var orig = pega.ui.grid.prototype.gridEventHandler;
pega.ui.grid.prototype.gridEventHandler = function(e,container)
{
var eventType = e.type;
var Event = pega.util.Event;
var target = Event.getTarget(e);
var eventKeyCode = e.keyCode;
var isContextMenuOpen = this.isCtxtMenuOpen();
if(( eventType=="keypress" && eventKeyCode==13) )
{
if(!(this.bTreegrid && (Dom.hasClass(target, "expandNode") || Dom.hasClass(target, "collapseNode"))) && !isContextMenuOpen) {
/* can improve the if conds if needed */
if(target && (target.type=="CHECKBOX" || target.type=="radio" || target.tagName=="SELECT"))
Event.stopPropagation(e);
else
Event.stopEvent(e);
}
}
if(eventKeyCode!=13)
{
orig.call(this,e,container);
}
}
</script>
Published May 10, 2015 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.