Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding objects to object array doesn't work
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Codage, syntaxe et commandes
Titre:
Adding objects to object array doesn't work
Divers
Thread ID:
01651859
Message ID:
01651859
Vues:
45
UPDATE. Never mind - sort of figured out.

Hi everybody,

I believe the code above used to work at some point but then a few changes by different people were done (in particular, adding classes for the columns) and the concatenation code doesn't work anymore. Do you see what may be wrong in that piece of code and how can I make it work again? I think the reason may be that our variables have more properties defined than the original array of objects.
var item = {
                name: "item",
                displayName: resourceFactory.getResource("Labels", "item"),
                canShowColumn: function () {
                    return $scope.searchParameters.itemId !== 0 || $scope.showSearchControls;
                }
            };

            var categories = [
                    {
                        name: "category",
                        displayName: resourceFactory.getResource("Labels", "category")
                    },
                    {
                        name: "subCategory",
                        displayName: resourceFactory.getResource("Labels", "subCategory"),
                        canShowColumn: function () {
                            return $scope.searchParameters.categoryId !== 0 ||
                                $scope.searchParameters.subCategoryId !== 0 ||
                                $scope.showSearchControls;
                        }
                    },
                    {
                        name: "blockHoldExpires",
                        displayName: resourceFactory.getResource("Labels", "blockHoldExpires"),
                        canShowColumn: function () {
                            return $scope.searchParameters.categoryId !== 0 ||
                                $scope.searchParameters.subCategoryId !== 0 ||
                                $scope.showSearchControls;
                        },
                        canShowValue: function (result) {
                            return result.type === 8;
                        },
                        filter: function (result) {
                            return result.bHoldDays +
                                " " +
                                (result.bHoldDays === 1 ? variables.day : variables.days) +
                                variables.priorAt +
                                " " +
                                result.bHoldExpires;
                        }
                    },
                    {
                        name: "allowItemSaleAfterExpire",
                        displayName: resourceFactory.getResource("Labels", "allowItemSaleAfterExpire"),
                        canShowColumn: function () {
                            return $scope.searchParameters.categoryId !== 0 ||
                                $scope.searchParameters.subCategoryId !== 0 ||
                                $scope.showSearchControls;
                        },
                        canShowValue: function (result) {
                            return result.type === 8;
                        },
                        filter: function (result) {
                            return result.allowItemSaleAfterExpire === 1 ? variables.yes : variables.no;
                        }
                    }
            ];

            var tableDefinition = [
                    {
                        name: "typeDescription",
                        displayName: resourceFactory.getResource("Labels", "type"),
                        canShowColumn: true,
                        colClasses: "twoHundred"
                    },
                    {
                        name: "startTime",
                        displayName: resourceFactory.getResource("Labels", "startTime"),
                        canShowColumn: true,
                        filter: function (result) {
                            var date = moment(result.startTime);

                            if (date.isValid()) {
                                return date.format("MM/DD/YYYY HH:mm:ss");
                            }

                            return "";
                        }
                    },
                    {
                        name: "endTime",
                        displayName: resourceFactory.getResource("Labels", "endTime"),
                        canShowColumn: true,
                        filter: function (result) {
                            var date = moment(result.endTime);

                            if (date.isValid()) {
                                return date.format("MM/DD/YYYY HH:mm:ss");
                            }

                            return "";
                        }
                    },
                    {
                        name: "numberOfDays",
                        displayName: "# " + resourceFactory.getResource("Labels", "days"),
                        canShowColumn: true,
                        colClasses: "seventyFive"
                    },
                    {
                        name: "maxSale",
                        displayName: resourceFactory.getResource("Labels", "max"),
                        canShowColumn: true
                    },
                    {
                        name: "department",
                        displayName: resourceFactory.getResource("Labels", "department"),
                        canShowColumn: true,
                        colClasses: "hundredFifty"
                    }
            ];

            if ($scope.showSearchControls) {
                $log.info('Adding categories and item into grid');
                sortColumn = "typeDescription";
                tableDefinition.concat(categories).push(item);
            } else if (isCategoriesExtras) {
                tableDefinition.concat(categories);

                if (isItemExtras) {
                    tableDefinition.push(item);
                }
            }
I can see that this line of code is executing:
if ($scope.showSearchControls) {
                $log.info('Adding categories and item into grid');
                sortColumn = "typeDescription";
                tableDefinition.concat(categories).push(item);
but then I display the tableDefinition and it is still 6 original items.

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Répondre
Fil
Voir

Click here to load this message in the networking platform