Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI grid - throw Error(kendo.format("Cannot call method '{0}' of {1} before it is initialized",t,r))

I have tabstrip with two tab. On each tab i have one grid with paging. My configuration for grid is on the client side. When I fast switch beetween tab then I get exception from javascript:

"throw Error(kendo.format("Cannot call method '{0}' of {1} before it is initialized",t,r))"

Below section for paging configuration in grid:

[...]

pageable: {
                    pageSizes: [5, 10, 20],
                    input: true
           },
[...]

Have you any idea how prevent this error?

like image 419
user2086031 Avatar asked Feb 19 '13 07:02

user2086031


1 Answers

I faced the same issue, and yes there is a fix for it, basically you just need to destroy the grid before you move to new tab...

The best way to tackle this is by using this function while will look for kendo grid and destroy them

$("[kendo-grid]").each(function(idx,kGrid){
                                var dataObj=$(kGrid).data();
                                for(mData in dataObj)
                                {
                                    if(typeOf dataObj[mData] != "string")
                                    {
                                        if("destroy" in dataObj[mData])
                                        {
                                            dataObj[mData].destroy();
                                        }
                                    }
                                }
                            })

Hope this helps...

like image 60
Manish Sathe Avatar answered Oct 20 '22 08:10

Manish Sathe