swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

this.column.$$valueGetter is not a function - after update to 8.0.0 #683

Closed enough1987 closed 3 years ago

enough1987 commented 7 years ago

Can Someone help me this this error?

ERROR TypeError: this.column.$$valueGetter is not a function at DataTableBodyCellComponent.get [as value] (index.js:3663) at Object.eval [as updateRenderer] (DataTableBodyCellComponent.html:14) at Object.debugUpdateRenderer [as updateRenderer] (core.es5.js:12651) at checkAndUpdateView (core.es5.js:12030) at callViewAction (core.es5.js:12340) at execEmbeddedViewsAction (core.es5.js:12312) at checkAndUpdateView (core.es5.js:12026) at callViewAction (core.es5.js:12340) at execComponentViewsAction (core.es5.js:12286) at checkAndUpdateView (core.es5.js:12031) at callViewAction (core.es5.js:12340) at execEmbeddedViewsAction (core.es5.js:12312) at checkAndUpdateView (core.es5.js:12026) at callViewAction (core.es5.js:12340) at execEmbeddedViewsAction (core.es5.js:12312)

amcdnl commented 7 years ago

1) Please fill out the form. 2) I do not see this on any of the demo pages, can you provide a demo.

arlowhite commented 7 years ago

This is related to my PR that added support for numeric properties. My code makes the assumption that setColumnDefaults is always called on columns before they are used. But this doesn't seem to be true in some cases. Probably related to #666

I'll take a look at this now.

arlowhite commented 7 years ago

@enough1987 How are you creating your columns? What ngx-datatable and Angular versions are you using?

enough1987 commented 7 years ago

I was able to solve this problem by changing method which setup columns . before I set values to this.columns , after changing it to buffer variable problem was gone.

  // set columns with options 
  private setColumns(columns) {
    console.log(" setColumns ", columns);
    if (this.columns.length) return;

    let cols = [];
    columns.forEach((col) => {
      if (col.type == "editable") cols.push({ prop: col.prop, name: col.name, cellTemplate: this.editTmpl, sortable: false });
      if (col.type == "readable") cols.push({ prop: col.prop, name: col.name, sortable: false });
      if (col.type == "date") cols.push({ prop: col.prop, name: col.name, cellTemplate: this.dateTmpl, sortable: false });
      if (col.type == "bool") {
        cols.push({
          prop: col.prop, name: col.name, cellTemplate: this.boolTmpl, sortable: false,
          trueImg: col.trueImg, falseImg: col.falseImg, resizeable: false, maxWidth: col.maxWidth, minWidth: col.minWidth
        });
      }
    });
    this.columns = cols;
  };
arlowhite commented 7 years ago

Ah, that makes sense. I understand what's happening now.

@amcdnl code similar to https://github.com/swimlane/ngx-datatable/pull/695 needs to be added that checks for mutation of columns (new column pushed to columns but columns setter not called). Do you want me to work on this? How much do you know about Angular change detection; where would you put this check? I need to test if ngOnChanges notifies if an array Input is mutated.

arlowhite commented 7 years ago

@amcdnl A related issue is if a user decides to just mutate a column object. For example, changing its prop and label directly to display a different data column. Should this be supported? If so, should it get a different $$id? Some defaults such as $$valueGetter would need to be re-evaluated.

joeveiga commented 3 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 3 years ago

This issue was closed because it has been stalled for 7 days with no activity.