angular-ui/ui-grid

Changing number of columns throws an exception

Open

#4.598 geöffnet am 29. Okt. 2015

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (1 zugewiesene Person)JavaScript (2.496 Forks)batch import
good first issue

Repository-Metriken

Stars
 (5.395 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

Version 3.0.7 of ui-grid.js line number 3139

This function is (obviously) assuming that it will ever be called with two objects, but it also gets called with the length of the columnDefs collection changes which causes it to crash on line 3142 because self.grid.options.columnDefs gets assigned n, which is a number.

I'm not sure if this is the complete fix, but checking for typeof n !== 'number' seems to fix the problem.

      function columnDefsWatchFunction(n, o) {
        if (n && n !== o && typeof n !== 'number' ) {
          self.grid.options.columnDefs = n;
          self.grid.buildColumns({ orderByColumnDefs: true })
            .then(function(){

              self.grid.preCompileCellTemplates();

              self.grid.callDataChangeCallbacks(uiGridConstants.dataChange.COLUMN);
            });
        }
      }

Contributor Guide