Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
175
Igx-Hierarchical-grid - Add Row to Top of Grid and Above and Below a selected Row
posted

Hello,

I have a requirement for my current project to be able to add Rows to the Top of an Hierarchical Grid, the bottom, and above and below a selected row (or rows).  I need to be able to do this at all grid levels, so the top level igx-hierarchical-grid and for each and every igx-row-island that could be potentially underneath.

As far as I can tell, the addRow functionality that is available for the heirarchical grid and row-islands only seems to be able to support adding to the bottom of a specified grid, is there currently a way to do the other functionality in some form?

Any insight would be appreciated.

Thanks,

-Randall Blevins

Parents
  • 29417
    Verified Answer
    Offline posted

    Hello Randall, 

    Thank you for posting in our forum. 

    By design the addRow API method adds the data record to the end of the data source. You can however modify the data array, to which the grid is bound to, and change the location of that record. Since the grid is bound to that array it will automatically reflect that change and the row will be rendered at the desired index. 

    For example: 

    this.grid1.addRow(this.product);
    const lastRec = this.data.pop();
    const targetIndex = 0;
    this.data.splice(targetIndex, 0, lastRec);    

     Here is a sample for your reference, where the new record is moved at index 0, so that it is added as the first record in the grid:

    https://stackblitz.com/edit/angular-5cdeng?file=src/app/grid/grid-editing-sample/grid-editing-sample.component.html

    Let me know if you have any additional questions or concerns. 

    Regards,

    Maya Kirova

Reply Children