We are encountering an issue when use the below function before iggrid to intialize the itself groupby feature and got an error like "cannot call methods on igGridGroupBy prior to initialization; attempted to call method 'option'"
var groupedColumns = $("#grid").igGridGroupBy("option", "groupedColumns");
Previously we used Infragistics version 13.1.20131.1012, in that, we are not getting any error in this function even though igGrid not to initialize the itself with the igGridGroupBy feature . But now we have upgraded to Infragistics version 14.2.20142.1018. After upgrading to this version we are getting this error.
http://jsfiddle.net/vrrenga/1q3b0pgw/
Not only the above methods. We are encoutnering this issue for the below method also.
$('selector').igGrid('destroy');$("selector").igTree("checkedNodes")
Any advice on this?
Hello Renganathan,
Please let me know if you need any further assistance with this matter.
Could you please let me know how do you enable the GroupBy on demand?
What I can suggest in order to check whether the GroupBy feature is enabled before calling its methods is looping trough igGrid features collection. If this feature appear in this collection this means that all its methods could be called. For example:
$("#btn1").click(function () { var gridFeaturesLength = $("#grid").igGrid("option", "features").length; if (gridFeaturesLength > 0) { for (var i = 0; i < gridFeaturesLength; i++) { if ($("#grid").igGrid("option", "features")[i].name == "GroupBy") { var groupedColumnsLength = $("#grid").igGridGroupBy("option", "groupedColumns").length; alert("There are " + groupedColumnsLength + " columns grouped."); } } }
$("#btn1").click(function () {
var gridFeaturesLength = $("#grid").igGrid("option", "features").length;
if (gridFeaturesLength > 0) {
for (var i = 0; i < gridFeaturesLength; i++) {
if ($("#grid").igGrid("option", "features")[i].name == "GroupBy") {
var groupedColumnsLength = $("#grid").igGridGroupBy("option", "groupedColumns").length;
alert("There are " + groupedColumnsLength + " columns grouped.");
}
Thanks for your reply.
Here is the most important part is we don't need to initialize the grid itself groupby feature at the beginning. We are enabling the groupby feature on demand basis.
Regards,
Renganathan.R
Thank you for posting in our community.
By design in order to use any of the igGrid feature options you need to first initialize the feature. I assume the reason why it was not throwing exceptions in version 13.1 is the jQuery and jQuery UI versions has undergone some changes.
I investigated your jsfiddle sample and If you uncomment the code that adds igGroupBy feature to the grid it works as expected. Additionally, I created a button wich is usd to destroy the igGrid using destroy method and it works as expected. When clicked the button destroys the grid successfully. For example:
$("#button2").click(function(){ $("#grid").igGrid("destroy"); });
$("#button2").click(function(){
$("#grid").igGrid("destroy"); });
The modified sample could be found at:
http://jsfiddle.net/1q3b0pgw/4/
If this is not helping you achieve you requirement could you please provide some additional information regarding your scenario and I would be glad to help you.