ng2-smart-table icon indicating copy to clipboard operation
ng2-smart-table copied to clipboard

TypeError: Cannot read property 'createFormShown' of undefined

Open Yelesee opened this issue 6 years ago • 3 comments

I have an issue with ng2-smart-table

i have a component

with this parts: station/ smart-table/ smart-table.component.ts smart-table.component.html station.module.ts station.component.ts station.component.html station.component.scss

and when i use ngx-smart-table selector in station.component.html it sends a lot of errors in the console and not shown the table i got this trace back ERROR TypeError: Cannot read property 'createFormShown' of undefined at Object.eval [as updateDirectives] (Ng2SmartTableTheadComponent.html:1) at Object.debugUpdateDirectives [as updateDirectives] (core.js:11922) at checkAndUpdateView (core.js:11315) at callViewAction (core.js:11556) at execComponentViewsAction (core.js:11498) at checkAndUpdateView (core.js:11321) at callViewAction (core.js:11556) at execEmbeddedViewsAction (core.js:11519) at checkAndUpdateView (core.js:11316) at callViewAction (core.js:11556)

what should i do?

Yelesee avatar Oct 01 '18 08:10 Yelesee

I am also facing this issue, What is the solution for this.

tanujlight avatar Jan 03 '21 11:01 tanujlight

Answering an old issue to serve as a reference to people that come here looking for a solution.

I had this problem and figured out that it occurs when there is an error that keeps initGrid method from completing:

initGrid() {
    this.source = this.prepareSource();
    this.grid = new Grid(this.source, this.prepareSettings());
    this.subscribeToOnSelectRow();
    this.subscribeToOnDeselectRow();
}

When there's an error in the Grid constructor, the this.grid reference stays undefined and later comes the Cannot read property 'createFormShown' of undefined error.

Most of the Grid constructor code is harmless but at some point it calls your DataSource.refresh() method and if this datasource refresh raises an exception everything goes south. The main problem is that the exception will not appear in logs and it is hard to follow the problem. It would be nice if errors in refresh were catched and logged.

In my case I had a class extending the ServerDataSource and overriding addFilterRequestParams method and there was an error in this method.

vipseixas avatar Oct 07 '21 12:10 vipseixas

This bug can be skipped if you get the data before "setting the settings", so the DataSource.refresh() call will not fail. For me, it happened only in a table that uses (userRowSelect) event.

jupmorenor avatar Jan 05 '22 23:01 jupmorenor