angular-ui/ui-grid

Importer Error(with rowEdit) - angular.min.js:108 requested row not found in rowEdit.setRowsDirty, row was: [object Object]

Open

#5.815 geöffnet am 15. Nov. 2016

Auf GitHub ansehen
 (6 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)JavaScript (2.496 Forks)batch import
help wanted

Repository-Metriken

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

Beschreibung

Implemented Importer functionality and everything works fine except when I get the following error on the console from adding new row to the grid on this line of code - allRows.unshift({

Error message: angular.min.js:108 requested row not found in rowEdit.setRowsDirty, row was: [object Object]

importerDataAddCallback: function (grid, newObjects) { var errorPRLS = ""; var errors = 0;

                if (newObjects) {                      
                    var cnt = newObjects.length;                
                    //turn on cancel button
                    grid.appScope.trigger.insert = true;
                    grid.appScope.trigger.importer = true;
                    var allRows = this.data;

                    angular.forEach(newObjects, function (row, index) {
                        PrecutReplenishmentService.requestId = row.precutPartNumber;
                        PrecutReplenishmentService.doGetMaster().success(function (response) {
                                if (response.data !== null) {
                                    if (typeof response.data.successful !== 'undefined' && !response.data.successful) {
                                        errorPRLS = errorPRLS == "" ? row.precutPartNumber : errorPRLS + ", " + row.precutPartNumber;
                                        errors++;
                                    } else {
                                            //instantiate local object
                                            var pRLColorDetail = new Object();
                                            pRLColorDetail.id = grid.appScope.prlColors[grid.appScope.trigger.setColorIndex].id;
                                            pRLColorDetail.pRLColor = grid.appScope.prlColors[grid.appScope.trigger.setColorIndex].pRLColor;
                                            //add to the top of collection
                                            allRows.unshift({
                                                id: 0,
                                                pRLColorId: grid.appScope.prlColors[grid.appScope.trigger.setColorIndex].id, //default data entity row to yellow
                                                pRLColorDetails: pRLColorDetail, //default data editor to yellow
                                                precutPartNumber: row.precutPartNumber,
                                                piecesToCut: row.piecesToCut,
                                                masterPartNumber: response.data.precutMaster,
                                                isDrill: response.data.isDrill,
                                                scheduledCutDate: grid.appScope.getCutDate()
                                            });
                                            //add to save counter
                                            grid.appScope.trigger.records++;
                                            //fire after all promisses have been resolved
                                            if (grid.appScope.trigger.records > 0) {
                                                if (cnt == grid.appScope.trigger.records + errors) {
                                                    $interval(function () {
                                                         var gridRows = grid.rows.filter(function (element) { return element.entity.id == 0 });
                                                         var dataRows = gridRows.map(function (gridRow) { return gridRow.entity; });
                                                         grid.api.rowEdit.setRowsDirty(dataRows);

Contributor Guide