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.

cellTemplate is not working

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

I’m doing everything in this plunkr but to no avail: https://embed.plnkr.co/FxZo4SxKLbCPxmNTveXr/

Expected behavior

The cellTemplate column option would actually allow me to author my own template and use it.

Reproduction of the problem

What is the motivation / use case for changing the behavior?

I need to dynamically create hyperlinks in my table

Please tell us about your environment:

  • Table version: 10.3.0
  • Angular version: 4.2.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

I am using chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Typescript / Html

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
wizarrccommented, Oct 20, 2017

@bberkobien when you use @ViewChild, make sure you initialize anything that depends on it on or after the ngOnInit lifecycle callback. In your case, initialize columns in the ngOnInit lifecycle.

columns = [];

ngOnInit() {
  columns = [
    {name:"Name", cellTemplate: this.template},
    {name:"Gender"},
    {name:"Company"}
  ];
}
1reaction
wizarrccommented, Oct 23, 2017

@bberkobien you can fix that by changing the lifecycle of the initialization from ngOnInit to ngAfterViewInit. I think it has something to do with when the @ViewChild is populated, which should always be after the view is initialized. I guess it’s probably a bug that you can even access it on the ngOnInit lifecycle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular ngx-datatable cellTemplate not loading - Stack Overflow
I was facing the same problem and I realized the templateRef was undefined, even if I initialized the columns inside ngOnInit .
Read more >
cellTemplate is not working when it's defined inside ng ...
DataGrid - cellTemplate is not working when it's defined inside ng-container using dxTemplate and column options are passed via Controller.
Read more >
GridViewColumn.CellTemplate does not work for me - MSDN
TestName is a string property . It does not display a TestName in the cell but just Header.ToString(). Even more it does not...
Read more >
Cannot read appointment information in cellTemplate | Angular
I changed it, but still it does not work. Has the data-object changed somehow? It does not seem to have the StartTime, EndTime...
Read more >
Gridview command binding not working for cell template
HiI am using wpf grid view as shown below. <telerik:RadGridView Grid.Row="1" ItemsSource="{Binding ExistingFilesCollection}" ...
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