Search code examples
javascriptextjscomboboxextjs-gridextjs6.2

Can not read property 'mergeAttributes' of null error when I try to insert new records using extjs grid editor


First of all, I am using 6.2 version of extjs framework.

I'm facing a problem to save new records using the ext.js grid with the "Ext.grid.plugin.RowEditing" plugin.

When I try to save a record, since the line does not have a combobox in the editor, it works fine.

However, when I add a combobox in the the line editor, the following error occurs:

Can not read property 'mergeAttributes' of null

By checking the extjs framework code, I noticed that the error occurs when the editor is exiting and the line is being populated with the modified content.

This occurs in following section of the Table.js file:

    cellSelector = me.getCellSelector(column);
    oldCell = oldRow.selectNode(cellSelector);
    newCell = newRow.selectNode(cellSelector);

    // Copy new cell attributes across. Use IE-specific method if possible.
    if (oldCell.mergeAttributes) {
        oldCell.mergeAttributes(newCell, true);
    } else {
        newAttrs = newCell.attributes;
        attLen = newAttrs.length;
        for (attrIndex = 0; attrIndex < attLen; attrIndex++) {
            attName = newAttrs[attrIndex].name;
            if (attName !== 'id') {
                oldCell.setAttribute(attName, newAttrs[attrIndex].value);
            }
        }
    }

Basically, the variable "oldCell" is not being populated by "oldRow.selectNode (cellSelector)".

In the first column I put an invisible column containing the Id of the record. This cell is being filled, however, any other cell, having the combobox or not, is returning "oldCell" as null.

Just to enforce, when I remove all comboboxes from editor it works.

This is also true only with new records.


Solution

  • Luckily the bug is easy to fix.

    I have a "render" in the column where the combobox is placed.

    An unhandled error was occurring in this render. So, I corrected it and the bug disappeared.