Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
185
Error when recreating the Grid
posted

I have specific requirements to dynamically update the filtering mechanism. I have figured out I need to 'destroy' the grid then recreate with the new filters (and columns etc). I have managed to get the columns to change dynamically but when I try to apply a filter I get this error

cannot call methods on igGridUpdating prior to initialization; attempted to call method 'destroy'

Here are some code snippets:

scope.changeView = function(v) {
    var grid = scope.element; //from directive
    if (grid.data("igGrid") != null) {
        grid.igGrid('destroy');
    }
    updateGrid(grid, v);
};

function updateGrid(grid, v) {
    scope.gridOptions = coreFunctions.gridOptions(); //from service
    scope.gridOptions.dataSource = scope.dataSource;
    var cols = JSON.parse(v.Json);
    cols = cols.fields;
    scope.gridOptions.columns = [];
    angular.forEach(cols, function(value, index) {
        scope.gridOptions.columns.push({ 'headerText': value, 'key': value, width: '200px' });
    });
    grid.igGrid(scope.gridOptions); //error occurs here!
    grid.igGrid('dataBind');
    grid.igGridFiltering("filter", ([{ fieldName: "Column1", expr: true, cond: "true" }]));
}

If required I can give a link which is demonstrating this error please PM me.

Parents Reply Children
No Data