Hi,
In our project we are using a collapsible group of columns. When adding a new row, it seems that if you interact with the expand/collapse icon, the RowEditExit event is triggered, so if someone gets halfway through entering information and decides to expand or collapse those columns (some of which are editable) this loses their work. Is there any way to prevent this from happening, just to keep the edit mode active regardless of the collapse state?
Thanks!
Adam
Thanks for your prompt and detailed response!
I'm having a bit of trouble putting this together - my first hurdle is that using this code:
Hello,
Thank you for reaching out to us regarding the issue you've encountered with the collapsible group of columns in the igx-grid component. I understand when editing a row and interacting with the expand/collapse icon inadvertently triggers the RowEditExit event, potentially leading to the loss of entered information.
Let's delve into the intricacies of the default behavior and why it triggers the RowEditExit event. The igx-grid component with collapsible column groups is designed to dynamically render columns and displayed records upon expansion or collapse. This dynamic rendering process necessitates triggering events such as RowEditExit to maintain consistency in data representation. Thus, when a column group expands or collapses, the grid re-renders its columns and the displayed records, inadvertently triggering the RowEditExit event because when you are in edit mode and the columns re-render the edit mode end.
I have been looking into your question and to address your requirement of maintaining the edit mode regardless of the collapse state, let's explore a comprehensive solution:
Here's a detailed breakdown of the solution approach:
<igx-grid #grid [data]="data" height="650px" [primaryKey]="'ProductID'" [rowEditable]="true" (rowEditEnter)="rowEditStart($event)" (cellEditEnter)="cellEditStart($event)" (rowEditExit)="rowEditExit($event)" ></igx-grid>
public rowEditStart(event){ this.editedRowId = event.rowID; }
public cellEditStart(event){ this.editedColumn = event.column.field; }
<igx-icon [attr.draggable]="false" #target="tooltipTarget" [igxTooltipTarget]="tooltipRef" [showDelay]="0" [hideDelay]="0" (click)="expandCollapse()" >{{ column.expanded ? 'expand_more' : 'chevron_right' }} </igx-icon>
public expandCollapse(){ this.isExpandOrCollapse = true; }
public rowEditExit(event){ if (this.isExpandOrCollapse) { setTimeout(() => { this.grid.getCellByKey(this.editedRowId, this.editedColumn).editMode = true; this.isExpandOrCollapse = false; }, 100); } }
By implementing this approach, you'll achieve your requirement of maintaining edit mode consistency in collapsible column groups, ensuring a seamless user experience.
The described scenario could be observed here:
In addition, I have prepared a small sample illustrating this behavior which could be found here. Please test it on your side and let me know how it behaves.
However, it's essential to note that in scenarios where expanding a column reveals new columns or collapsing a column hides the edited column due to the collapsible column groups themselves, this approach may not suffice. When a column is added or hidden, it cannot remain in edit mode. In such cases, additional checks and custom implementation based on your specific logic and code may be necessary to ensure the desired behavior.
Regards,
Georgi Anastasov
Entry Level Software Developer
Infragistics