Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onComponentInitFunction doesnot working #364

Open
audrys opened this issue May 19, 2017 · 13 comments
Open

onComponentInitFunction doesnot working #364

audrys opened this issue May 19, 2017 · 13 comments

Comments

@audrys
Copy link

audrys commented May 19, 2017

Hi,
The method onComponentInitFunction in settings of table (as in demo site) is not fiting when i install ng2-smart-table from npm. My table settings:
settings = {
columns: {
User: {title:"Users"},
Plan{
title: "Plan",
type: 'custom',
renderComponent: IconViewComponent,
onComponentInitFunction(instance) {
instance.click.subscribe(row => {

                console.log('event clicking');
                alert(`${row.User} clicked!`);
            });
        } 

},
};
The IconViewComponent is rendering correctly.
Do I need to set some extra parameters or any other requirements?

Thanks in advance
Audrius

@RunningFly
Copy link

Had the same problem. Appears to be an issue with the packages in npm. If I build from source, it works as expected.

@biharygergo
Copy link

Hi! Could you provide a detailed solution? I'm facing the same issue. Thanks!

@millermo
Copy link

You need download from this repository and build the module. Use gulp

git clone https://github.com/akveo/ng2-smart-table.git
cd ng2-smart-table
npm install
gulp build:release
copy folder from dist to your project in node_modules

@RunningFly
Copy link

Keep in mind that the root of the git repo contains the demo app. The actual source for ng2-smart-table is in the subfolder "<path_to_local_git_repo>/src/ng2-smart-table".
I used the following command to update my projects package.json dependencies.
npm install --save "<path_to_local_git_repo>/src/ng2-smart-table"
Causing npm to use the local folder instead of downloading the packages from the web.
Note: this path can also be relative to you projects path. i.e. "../ng2-smart-table/src/ng2-smart-table"

@pakajni
Copy link

pakajni commented May 23, 2017

I think the latest version does not have rowData accessible through ViewCell interface. Only value is there. So rowData comes as undefined.

@audrys
Copy link
Author

audrys commented May 23, 2017

Hi,
I rebuild the module:
"git clone https://github.com/akveo/ng2-smart-table.git
cd ng2-smart-table
npm install
gulp build:release"
and replace node_modules to ng2-smart-table from dist (copy - paste).
Does not working,
Any suggestion?
Thanks in advance

@millermo
Copy link

millermo commented May 24, 2017

@audrys you need emit the event with variable click
in the template
(click)="click.emit(this)"

In the component

export class IconViewComponent implements ViewCell, OnInit {
	renderValue: string;
       @Input() rowData: any;

      @Output() click = new EventEmitter<any>();

onComponentInitFunction(instance)

  instance.click.subscribe(event => {
           console.log("event clicking");
           console.dir(event);
      });

View in console
event clicking
IconViewComponent
click: EventEmitter
rowData: Object
value: "xxxx"
proto: Object

@pakajni you emit the component (this) or rowData variable, the example only emit value

@RunningFly
Copy link

Agreed that you need to emit the event. However, I still believe there is something wrong with the packages in the npm repository. If you search the JS in those packages, there is no sign of he onComponentInitFunction being called. This is contrary to the trans-compiled source checked out from git.

@millermo
Copy link

millermo commented May 24, 2017

This fix was 19 days ago, possibly have not changed version and the package has not been updated in NPM

067a346

@hcaceres0515
Copy link

I still have the same problem. I did
"git clone https://github.com/akveo/ng2-smart-table.git
cd ng2-smart-table
npm install
gulp build:release"
and replace node_modules to ng2-smart-table from dist (copy - paste)."

Thanks

@KeaganFouche
Copy link

Thank you! I updated my ng2-smart-table from 1.1.0 to 1.2.2 and it resolved it.

@Gaabiriel
Copy link

@KeaganFouche
It worked for me!!!

@dfilho
Copy link

dfilho commented Mar 23, 2018

Just update the ng2-smart-table and works for me! Thanks everbody

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants