This is a migrated thread and some comments may be shown as answers.

strange javascript error in grid

6 Answers 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker asked on 11 Apr 2012, 05:01 PM
I have a grid which uses advanced databinding to a collection of custom objects. My declaration is below. The grid exists in a pageview of a tab which is not selected by default. When I switch to the tab this grid is on, I get the following javascript error and the grid does not display:

a[d].get_visible is not a function

which points to line 1561 of the script resource:
var a=this._owner.get_masterTableView().get_columns(); 
for(var d in a){if(!a[d].get_visible()){this._owner.get_masterTableView().showColumn(d); //error is here

when I switch tabs, I get a reference to the grid client-side and repaint. What is odd is, if I select the tab this grid is on by default, it binds and displays properly. It is only when the page loads with a different tab by default that this error occurs when I switch to this grid's tab. Anyhow, this page is fairly complicated, so I first wanted to see if you can tell from the error and what it is pointing to, what might be causing this error. I checked the datasource and it has 31 rows and data for each column in the grid declaration, so I don't think it is a data issue.

Grid Declaration:
<telerik:RadGrid id="rgDataSCHX"
                        runat="server"
                        AutoGenerateColumns="False"
                        Skin="Office2007"
                        AllowSorting="False"
                        AllowPaging="False"
                        Height="100%"
                        ShowFooter="False"
                        >
 
            <MasterTableView 
                        DataKeyNames="Id"
                        ClientDataKeyNames="Id"
                        Width="100%"
                        TableLayout="Fixed"
                        UseAllDataFields="True"
                        >
                 
                <Columns>
                    <telerik:GridBoundColumn HeaderStyle-Width="100px" HeaderText="Group" DataField="GroupName"  />
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="P(#N)" DataField="PlacementStatCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Placement Count"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="P(#D)" DataField="PlacementPoolCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Placement Pool"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="P(%)" DataField="PlacementPctString" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Placement %"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="60px" HeaderText="WA(#N)" DataField="WorkAssessmentPlacementStatCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Assessment Count"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="WA(#D)" DataField="WorkAssessmentPlacementPoolCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Assessment Pool"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="WA(%)" DataField="WorkAssessmentPlacementPctString" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Work Assessment %"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="CP(#N)" DataField="NonWorkPlacementStatCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Community Placement Count"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="CP(#D)" DataField="NonWorkPlacementPoolCount" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Community Placement Pool"/>
                    <telerik:GridBoundColumn HeaderStyle-Width="55px" HeaderText="C(%)" DataField="NonWorkPlacementPctString" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderTooltip="Current Community Placement %"/>
                </Columns>
                <CommandItemTemplate>
                 
                </CommandItemTemplate>
            </MasterTableView>
            <ItemStyle BorderStyle="None" />
            <GroupingSettings GroupByFieldsSeparator="" CaseSensitive="False" />
            <ClientSettings  AllowExpandCollapse="False">
                <ClientEvents OnFilterMenuShowing=""  />
                <Selecting AllowRowSelect="False"  />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="100%" FrozenColumnsCount="1" />
                <Resizing AllowColumnResize="False" ClipCellContentOnResize="False" EnableRealTimeResize="False" ResizeGridOnColumnResize="True"/>
            </ClientSettings>
            <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" IgnorePaging="true"  >
                <Excel Format="ExcelML" FileExtension="xls" />
            </ExportSettings>
        </telerik:RadGrid>

6 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 17 Apr 2012, 01:15 PM
Hello,

We have not observed such problem with our controls suite.

Could you open a formal support ticket and send us a sample project which replicates the issue?

Thus we will be able to investigate the causes of this issue and will let you know the conclusion.

Regards,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 17 Apr 2012, 04:55 PM
creating a stripped out version is proving difficult. Can you provide any insight as to what the javascript is doing where the error is occurring? It would appear it is is trying to get the visibility of some object which does not have the get_visible method available. is there any way to tell what objects are getting looped through to try and deduce which one might be throwing the error?
0
Andrey
Telerik team
answered on 19 Apr 2012, 02:59 PM
Hello,

The specified code is used to loop through RadGrid columns and it is checking which column is not visible and it is calling the showColumn() function.

The reason why I am asking you for stripped down version of your project is that we could not replicate the problem on our side and no one else has reported this issue. Your particular setup is important because the combination of all controls is causing the error to reproduce.

Other than that I think there is not much to do.
Greetings,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Anon
Top achievements
Rank 1
answered on 24 May 2012, 02:06 PM
I had the simialr/same issue.
The error in IE was 'Object doesn't support property or method 'get_visible' just in case anyone is using a search engine.
After upgrading the Telerik components the same error occured for me.

Using Firebug I found that the
this._owner.get_masterTableView().get_columns()
method was returning 13 columns, which was fine, but there was also an 'erase' method included that was not part of the core JavaScript array.

Eventually found the issue back to a (seperate companies) script file with nothing to do with the executing code in question. It had modified the core JavaScript Array object:
Array.prototype.erase = erase;

The Telerik code (in onGridFrozenResized) below loops through the code as below:
var a = this._owner.get_masterTableView().get_columns();
for (var d in a) {
    if (!a[d].get_visible()) {
        this._owner.get_masterTableView().showColumn(d);
    }
}


Due to not using an index the 'erase' method was being included as the 14th item which obvioulsy doesn't have a get_visible() method.

The Telerik code could be modified to use an index like:
for (var d = 0; d < a.length; d++) {
and the issue wouldn't occur.

Our solution (if you can call it that) was to carry out a search on the code for the 'erase' method. From this we found that we werent using the seperate companies erase method and commented it out.
Could also search for 'Array.prototype'.

Hope this helps.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 24 May 2012, 02:22 PM
thanks for chiming in Anon. I took a look and my app does include a global script library which contains the following;
//******************Array Utility Functions****************************
 
if (!Array.prototype.contains){
        Array.prototype.contains = function(obj){
    var len = this.length;
    for (var i = 0; i < len; i++){
      if(this[i]===obj){ return true;}
    }
    return false;
  };
}
 
if(!Array.prototype.containsAny){
      Array.prototype.containsAny = function(obj){
            if(isArray(obj)){
                  for(var i=0;i<obj.length;i++){
                        if(this.contains(obj[i])){ return true;}
                  }
                  return false;
            }else{throw new TypeError();}
      }
}


i haven't had time to tell whether removing this will avoid the issue described in this thread, however, I don't have a great deal of control over this since this script is used everywhere and the particular Array functionality may be necessary in other parts of the site. Can the folks at Telerik confirm that having javascript like what Anon mentined or what I have here would cause this issue. If so, do you think you can implement the fix Anon suggested to avoid this issue?
0
Andrey
Telerik team
answered on 29 May 2012, 09:56 AM
Hi,

Yes, Anon is right and we will log this as bug in our current release, You could expect the bug to be fixed for the next major release.

Please, excuse us for any inconvenience caused.

All the best,
Andrey
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Answers by
Andrey
Telerik team
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Anon
Top achievements
Rank 1
Share this question
or