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 opened on Nov 15, 2016

View on GitHub
 (6 comments) (2 reactions) (0 assignees)JavaScript (2,496 forks)batch import
help wanted

Repository metrics

Stars
 (5,395 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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