Skip to content
This repository was archived by the owner on Feb 2, 2025. It is now read-only.

Adding new column to dtColumns, does not show up in table #509

Closed
ottoyiu opened this issue Nov 16, 2015 · 1 comment
Closed

Adding new column to dtColumns, does not show up in table #509

ottoyiu opened this issue Nov 16, 2015 · 1 comment

Comments

@ottoyiu
Copy link

ottoyiu commented Nov 16, 2015

Hello there,

I'm trying to add a new column dynamically, before calling dtInstance.changeData. However, it does not get rendered as a new column in the table.

        $scope.dtColumns = [
            DTColumnBuilder.newColumn('name').withTitle('name')
        ];
        $scope.retrieveNodes = function (kind) {
            return function () {
                var deferred = $q.defer();
                $http.get("blahblahblah").then(
                    function (res) {
                        deferred.resolve(res.data.result);
                    });
                return deferred.promise;
            };
        };
        $scope.changeKind = function (kind, dtInstance) {
            $scope.dtInstance = dtInstance;
            $log.debug(dtInstance.changeData, $scope.dtInstance.changeData);
            if (angular.isDefined($scope.dtInstance.changeData)) {
                $scope.dtColumns = [
                    DTColumnBuilder.newColumn('name').withTitle('name'),
                    DTColumnBuilder.newColumn('newcolumn').withTitle('newcolumn'),
                ];
                $scope.dtInstance.changeData($scope.retrieveNodes(kind));
            }
        };

I get this Javascript error when I try changing data.

TypeError: Cannot read property 'style' of undefined
    at Ha (jquery.dataTables.min.js:60)
    at ia (jquery.dataTables.min.js:47)
    at HTMLTableElement.<anonymous> (jquery.dataTables.min.js:94)
    at Function.m.extend.each (jquery.min.js:2)
    at m.fn.m.each (jquery.min.js:2)
    at m [as dataTable] (jquery.dataTables.min.js:84)
    at h.fn.DataTable (jquery.dataTables.min.js:162)
    at renderDataTable (angular-datatables.js:711)
    at angular-datatables.js:1024
    at angular.js:17855(anonymous function) @ angular.js:12477
jquery.dataTables.min.js:60 Uncaught TypeError: Cannot read property 'style' of undefined

Is there anything I'm doing wrong?

@ottoyiu ottoyiu closed this as completed Nov 19, 2015
@ottoyiu
Copy link
Author

ottoyiu commented Nov 19, 2015

Duplicate bug: #262

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant