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
220
Tree-grid - Adding Add New Row button on delete
posted

Hi,

In my project we are using the tree-grid component.  We rely on using the empty grid template to add a new row when the grid is empty which is fine when you load the component.  However, when all entries are deleted, the empty grid template no longer shows.  Following some investigation, the data.length value is zero, however the dataLength value remains at 1 for some reason, which is the actual prerequisite for the empty grid template to show.  We are not using any paging, grouping or filtering and there shouldn't be any mismatch between the primary and foreign keys so I'm not sure why this is happening.  I've tried using markForCheck and detectChanges but this also makes no difference.  Can you think of any reason why this might be?

Thanks!

  • 2660
    Offline posted in reply to Adam Drew

    Hi Andrew,

    Thank you for posting to Infragistics Community!

    I have been looking into your question and created this StackBlitz sample in an effort to investigate a similar scenario.

    It uses the emptyGridTemplate to add a button adding the first row. On my side, I am not able to reproduce the reported behavior, and the empty templates are always shown.

    Could you please, check out the sample and compare the discrepancies between it and your application that may cause the unwanted behavior?

    Additionally, looking at the dataLength property of the base grid class, it is marked as internal and is not meant to be used as part of the public API. As visible from its getter, in case transactions are enabled for the grid, this variable resolves to the length the data plus the number of the rows added in pending transactions. I am wondering if this is the case on your side as well?

    Having this in mind, you could investigate this with your current implementation by clearing the transactions once all entries are deleted.

    In conclusion, since the isolated sample does not exhibit this behavior, please feel free to fork and modify it in order to demonstrate what you are currently attempting. Having a working sample on our side, which we can debug will be highly appreciated so we can proceed with assisting you.

    Best regards,
    Bozhidara Pachilova
    Associate Software Developer

  • 220
    Offline posted

    In addition, I should add I have found a workaround where I use an ngIf on the grid and set a boolean on a timer to true and false to manually reload the whole component but obviously this is not ideal.