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

from moving from 3.x to 4.x set data source not working #845

Closed
Wingie opened this issue Apr 18, 2016 · 5 comments
Closed

from moving from 3.x to 4.x set data source not working #845

Wingie opened this issue Apr 18, 2016 · 5 comments

Comments

@Wingie
Copy link

Wingie commented Apr 18, 2016

if (!$scope.gridOptions.datasource) { // must attach datasource only once
        $scope.gridOptions.datasource = $scope.dataSource;
        console.log($scope.gridOptions)
        $scope.gridOptions.api.onNewDatasource();
      }

i'm getting an error

build.min.js:25996 TypeError: Cannot read property 'onNewDatasource' of undefined
    at init_datasource (build.min.js:131911)
    at new SearchResultProjectsCtrl (build.min.js:131633)
    at Object.invoke (build.min.js:17364)
    at extend.instance (build.min.js:22615)

to note that i did not need the $scope.gridOptions.api.onNewDatasource(); when i was on 3.0.3
just updated now and went through documentation and found this change.
without the .api.onNewDatasource(); the issue was that nothing was displayed on the screen

@ceolter
Copy link
Contributor

ceolter commented Apr 21, 2016

onNewDatasource() is not used in the new version. please check the docs.

@ceolter ceolter closed this as completed Apr 21, 2016
@GustavSt
Copy link

In the Datasource section of the docs it says this is possible way to add datasource.

// way 1 - set the the datasource using the API
gridOptions.api.setDatasource(myDataSource);

// way 2 - set the the datasource directly and inform the grid a new datasource is there
gridOptions.datasource = myNewDatasource;
gridOptions.api.onNewDatasource();

@ceolter
Copy link
Contributor

ceolter commented Apr 26, 2016

sorry for this. docs are out of date. i've fixed and they will be updated with the next release.

@dtslvr
Copy link

dtslvr commented Jun 6, 2016

Could you please share the solution with us?

@ceolter
Copy link
Contributor

ceolter commented Jun 7, 2016

use:

// way 1 - set the the datasource using the API
gridOptions.api.setDatasource(myDataSource);

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

4 participants