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.
Hello Paul,
Please feel free to contact us in case that you need any further assistance with this matter.
Hi Paul de Wit,
Thank you for the information. I have tried to reproduce this with the information you have provided with a simple sample (without Angular) and have not been able to experience this behavior. When I run the page, an initial igGrid loads. When I click the Change View button, the grid is destroyed and initialized without any errors.
Could you please provide the link to the site that demonstrates this error so I may better assist you? If you are concerned with posting it publicly on the forums, I can create a private support case for you to provide me with the link.
I have attached the sample I have been testing with for reference. Please test this on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the script versions we are using. My test was performed using version 14.2.20142.2140 in IgniteUI 2014 Volume 2.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Looking forward to hearing from you.
Here is the stacktrace
Error: cannot call methods on igGridUpdating prior to initialization; attempted to call method 'destroy' at Function.jQuery.extend.error (http://localhost:56829/app/assets/js/jquery-1.8.3.js:477:9) at HTMLTableElement.<anonymous> (http://localhost:56829/scripts/jquery-ui-1.11.2.min.js:6:9223) at Function.jQuery.extend.each (http://localhost:56829/app/assets/js/jquery-1.8.3.js:611:20) at jQuery.fn.jQuery.each (http://localhost:56829/app/assets/js/jquery-1.8.3.js:241:17) at e.widget.bridge.e.fn.(anonymous function) [as igGridUpdating] (http://localhost:56829/scripts/jquery-ui-1.11.2.min.js:6:8872) at $.widget._initFeature (http://localhost:56829/app/infragistics/js/modules/infragistics.ui.grid.framework.js:30:18635) at null._initFeature (http://localhost:56829/scripts/jquery-ui-1.11.2.min.js:6:7983) at $.widget.dataBind (http://localhost:56829/app/infragistics/js/modules/infragistics.ui.grid.framework.js:26:30510) at null.dataBind (http://localhost:56829/scripts/jquery-ui-1.11.2.min.js:6:7983) at $.widget._create (http://localhost:56829/app/infragistics/js/modules/infragistics.ui.grid.framework.js:26:10357)
Hi Micahel, here is coreFunctions.gridOptions
{ height: "600px", width: "100%", primaryKey: "CustomerID", autoCommit: true, autoGenerateColumns: false, fixedHeaders: false, features: [ { name: "Updating", enableAddRow: false, enableDeleteRow: false, caseSensitive: false }, { name: "Sorting", type: "local" }, { name: "Hiding" }, { name: "Filtering" }] };
Hello Paul de Wit,
Thank you for posting in our forums!
Please answer the following questions so I may better assist you.
1. What igGrid options/properties are being returned from coreFunctions.gridOptions()? Could you provide the full object for me?
2. Are any events that are accessing igGridUpdating provided by coreFunctions.gridOptions()?
3. Could you please provide a stack trace of when the error occurs?