angular-ui/ui-grid

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

Open

#5815 aperta il 15 nov 2016

Vedi su GitHub
 (6 commenti) (2 reazioni) (0 assegnatari)JavaScript (2496 fork)batch import
help wanted

Metriche repository

Star
 (5395 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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);

Guida contributor