Angularjs Datatable does not load table data when using a variable in a column heading

Asked

Viewed 43 times

1

Hello, I’m using the Datatable Angularjs https://l-lin.github.io/angular-datatables/archives/#! /changeOptions. I need the title of a column to be dynamic, using a variable in it. But when I do, when trying to update table data it doesn’t update, even the request (on the Chrome network) is bringing all the data correctly. Table only updates with current data if you change "results per page".

To leave the title of the dynamic column I am setting the dtColumns again whenever the variable changes and puts it in the function withTitle() in that way withTitle(variableName)

So the definition of the columns was like this:

vm.dtColumns = [
        DTColumnBuilder.newColumn('id').withTitle('ID'),
        DTColumnBuilder.newColumn('firstName').withTitle('First name'),
        DTColumnBuilder.newColumn('lastName').withTitle('Last name').notSortable()
    ];

And the title change of the specific column was like this:

function changeColumns(variableName) {
        vm.dtColumns = [
            DTColumnBuilder.newColumn('id').withTitle('ID'),
            DTColumnBuilder.newColumn('firstName').withTitle(variableName),
            DTColumnBuilder.newColumn('lastName').withTitle('Last name').notSortable()
        ];
    }

If instead of variableName I put the same name in which the column was set, the table works normally.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.