0

I have the following problem:

>>>>>>> Link to a JsFiddle demonstration >>>>>>

I have used the collapse example, and added getItemMetadata method.

dataView.getItemMetadata = function (row) {
        var thtId = data[row].id;
        if (data[thtId + 1] && data[thtId + 1].indent > data[thtId].indent) {
            return { 'cssClasses': 'parentClassName' }
        }
    };

This works fine until I try to collapse and expanding my rows. Than I get the following error (only on expanding):

Uncaught TypeError: Cannot read property 'id' of undefined

From my experience, this error accrue when the dataView looses the children's properties. I investigated more and saw that the code fall in the appendRowHtml function (slick.grid.js#1217).

Does anyone has expirience with collapsing feature & getItemMetadata?

Thank You!

neoswf
  • 4,730
  • 6
  • 39
  • 59

1 Answers1

1

Solution been held by @Tin, creator of SlickGrid

The exception is occurring in "var thtId = data[row].id", where "row" is out of bounds. You should check if "data[row]" exists before accessing the "id" property. The grid asks for a metadata for a non-existent row, which could be interpreted as a bug, but it is still useful to be able to customize the empty last row (the one used for adding new entries), so it kinda makes sense.

https://groups.google.com/forum/#!topic/slickgrid/65vPmzXsLMQ

neoswf
  • 4,730
  • 6
  • 39
  • 59