Search code examples
angularprimengprimeng-datatable

Primeng Datatable rowTrackBy


I have searched the web for a decent example of primeng datatable with rowTrackBy. Documentation is incomplete and does not say much. Is there anyone out there that can help?


Solution

  • It's very similar to the trackBy function in ngFor. You just need to provide a function with the index and the item as arguments and you return what you are tracking by. For example

    trackByFunction = (index, item) => {
        return item.id // O index
    }