vendredi 31 juillet 2015

Overriding slickgrid getItemMetadata cause cell data to blank on select

I'm really not sure what is causing this. I wanted to apply some custom styling to my slickgrid, so I defined a custom getItemMetadata() function and added it to my dataView. At first I thought it was working fine, until I noticed that one some of the cells I apply the styling to, problems appeared.

When I click on the cell-title cell, all is fine, but when I click on any other cell, their data disappears and the cell doesn't change to the 'active' colour. I have another row, which is unselectable, and this problem doesn't appear there. The rows I don't apply any styling to are fine.

My getItemMetadata() function:

function getItemMetaData(row){
    if (grid){
        var rowData = grid.getDataItem(row);
        if(rowData){
            // set the first row unselectable and non-editable class
            if (row == 0  && rowData.isparent){
                return {selectable: false,
                        'cssClasses': "non-editable-row"
                    };
            }
            // set the row non-editable class for certain types
            if(rowData.type == 'foo' || rowData.type == 'barr' ){
                return {'cssClasses': "non-editable-row"};
            }   
        }
    }
    return {};
}

The non-editable-row css class:

div.non-editable-row{
   background-color: #F8F8F8;
}

Has anyone else encountered this?

Aucun commentaire:

Enregistrer un commentaire