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

[Solved] hideColumn() throws error Cannot read property 'style' of undefined

2 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kuangyi
Top achievements
Rank 1
Kuangyi asked on 31 Jul 2012, 03:46 PM

$('#Grid2').data('tGrid').hideColumn(i) throws error Cannot read property 'style' of undefined

 

Steps to reproduce

 

Add the grid

 

 @(
 Html.Telerik().Grid(Model.Grid.GridRowViewModels)
    .Name(
"Grid2")
     .Columns(columns =>
    {
        
Action<intstringType> addColumn = (i, title, type) =>
        {
            columns.Bound(column => column.GridRowCellViewModels[i].Data)
                .Title(title);
        };
        
for (int colIndex = 0; colIndex < Model.Grid.ColumnCount; colIndex++)
        {
            addColumn(colIndex, Model.Grid.Titles[colIndex], Model.Grid.Types[colIndex]);
 
        }
    })
    .ClientEvents(e => e.OnLoad(
"onGridLoad2"))
         
)

 

The onload function, hide all the columns

 

for (var i = 0; i < $('#Grid2').data('tGrid').columns.length; i++) {
            $(
'#Grid2').data('tGrid').hideColumn(i);      
    }

 

Now in the console

 

$('#Grid2').data('tGrid').showColumn(i)

 

And then

$('#Grid2').data('tGrid').hideColumn(i) would throw an error

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 02 Aug 2012, 01:46 PM
Hi Kuangyi,

Judging by your account data, you seem to be using a very old version of the Grid. The latest one does not have the described problem.

Regards,
Dimo
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Kuangyi
Top achievements
Rank 1
answered on 02 Aug 2012, 03:16 PM
alright, thanks.
Tags
Grid
Asked by
Kuangyi
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Kuangyi
Top achievements
Rank 1
Share this question
or