question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Field columns of DatatableComponent instance is undefined in 11.0.3

See original GitHub issue

I’m submitting a … (check one with “x”)

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

Field columns of DatatableComponent instance is undefined after table initiated Expected behavior

DatatableComponent.columns should be array of TableColumns objects for every column presents. Reproduction of the problem

Stackblitz demo: https://stackblitz.com/edit/angular-vpi2bx?file=app%2Fhello.component.ts

Just @ViewChild the table and check it after table is initiated. What is the motivation / use case for changing the behavior?

I was using 9.3.1 before upgrading to 11.0.3 due to an upgrade to Angular 5. In order to be able to toggle a custom checkbox column on an external event, I had to added/removed a column object representing the checkbox column to/from columns array. I named it checkboxColumn. Noted that I constructed the column in TS code, then add it to columns array on an external event, because if I just add the column directly in HTML, there isn’t any hook on table view successfully initiated event so that I can hide that column immediately. Basically I want the checkbox column to only show when user request for checkbox selection mode. I don’t find any notes about this change so I guess it’s a bug.

I was able to get the columns array though, by accessing the TableComponent.bodyComponent.columns - but if I try to add checkboxColumn to that array, this error is thrown: this.column.$$valueGetter is not a function May be doing that is not recommended? I’m not sure.

Also the column object I constructed and how I added it to bodyComponent.columns array:

  private checkboxColumn: any = {
    flexGrow: 1,
    sortable: false,
    canAutoResize: false,
    draggable: false,
    resizeable: false,
    name: 'Select'
  };

this.datatable.bodyComponent.columns = [this.checkboxColumn, ...this.datatable.bodyComponent.columns];

Please tell us about your environment:

Ubuntu 16.04 x64, Visual Studio Code, npm, …

  • Table version: 11.0.3

Tried with 11.0.2, issue is still there.

  • Angular version: 5.1.0-beta.0

Checked with 5.0.1, it’s still there

  • Browser: [Chrome 59 | Firefox 56 ]
  • Language: [ TypeScript 2.4 ]

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
amcdnlcommented, Nov 22, 2017

Hi - Sorry for the delay. So many people asking for help and its just me.

I’d recommend not accessing the columns like this: this.datatable.bodyComponent.column. You want to make sure to access it through the main component to make sure everything reacts properly.

If you can make a stackblitz demo that would be very helpful in helping me debug it.

0reactions
nhducseuitcommented, Nov 24, 2017

It’s pretty weird that when I specify columns input in datatable declaration like [columns]="[{name:'Name'},{name:'Gender'},{name:'Company'}]" then the column field won’t be undefined anymore.

Is this a requirement?


But in another way, doing this in my component cause many weird behaviors when toggling columns. So I think that’s not an option …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my react table say that columns are undefined?
It seems to be trying to create a map from the columns but throwing an error because columns is undefined. I am passing...
Read more >
Lighting Component DataTable Columns display related fields
Hello Devs, I have a component that is going to be using a <lightning:datatable /> object I am attempting to set the cols...
Read more >
Datatable – Lightning Web Component for Flow Screens
While interacting with the datatable, the user can sort columns, filter columns, change column widths, wrap or clip the displayed text, ...
Read more >
columns.data - DataTables
Set the data source for the column from the rows data object / array. ... The result of this is that an object...
Read more >
react-data-table-component - npm
A simple to use declarative react based data table. Latest version: 7.5.3, last published: 4 months ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found