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

ng-grid does not allow 'controller as' syntax for options.data #1040

Closed
rkrdovrgs opened this issue Mar 12, 2014 · 0 comments
Closed

ng-grid does not allow 'controller as' syntax for options.data #1040

rkrdovrgs opened this issue Mar 12, 2014 · 0 comments

Comments

@rkrdovrgs
Copy link

I had to change the current ng-grid implementation to allow 'controller as' syntax for options.data to:

var dataWatcher = function (a) {
    grid.data = $.extend([], a);
    grid.rowFactory.fixRowCache();
    angular.forEach(grid.data, function (item, j) {
        var indx = grid.rowMap[j] || j;
        if (grid.rowCache[indx]) {
            grid.rowCache[indx].ensureEntity(item);
        }
        grid.rowMap[indx] = j;
    });
    grid.searchProvider.evalFilter();
    grid.configureColumnWidths();
    grid.refreshDomSizes();
    if (grid.config.sortInfo.fields.length > 0) {
        grid.getColsFromFields();
        grid.sortActual();
        grid.searchProvider.evalFilter();
        $scope.$emit('ngGridEventSorted', grid.config.sortInfo);
    }
    $scope.$emit("ngGridEventData", grid.gridId);
};
if (typeof options.data === "string") {

    $scope.$parent.$watch(options.data, dataWatcher);
    $scope.$parent.$watch(options.data + '.length', function () {
        dataWatcher($scope.$eval(options.data));
    });
}
else {

    var dataFunctionName = '$myNgGridData';
    $scope.$parent[dataFunctionName] = options.data;

    $scope.$parent.$watch(dataFunctionName + '()', dataWatcher);
    $scope.$parent.$watch(dataFunctionName + '().length', function () {
        dataWatcher($scope.$eval(dataFunctionName + '()'));
    });
}
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

2 participants