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

"Cannot read property 'style' of undefined" calling hideColumn() on a grid

1 Answer 688 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Blake
Top achievements
Rank 1
Blake asked on 23 Apr 2021, 07:49 PM

I am trying to do a simple test where a button click hides the first column of a grid.  Unfortunately, there is a JavaScript error in the Kendo UI layer (2019.2.619) when my call happens.  Is there some easy way to fix this?         

The error:
Uncaught TypeError: Cannot read property 'style' of undefined

    at init.hideColumn (kendo.all.js:65537)
    at HTMLButtonElement.onclick (CustomerCode:312)

 

<div>
    <button id="toggler" onclick="$('#SomeGrid').data('kendoGrid').hideColumn(0);" > Go </button>
</div>
<div>
        Html.Kendo().ReadOnlyGrid(Model,
            "SomeController",
            ViewContext,
            "SomeGrid",
...

1 Answer, 1 is accepted

Sort by
1
Mihaela
Telerik team
answered on 27 Apr 2021, 01:24 PM

Hello Blake,

Thank you for the code snippet.

Based on the provided information, I assume that you have created a custom extension of the Kendo UI Grid.

I have configured an ASP.NET Core demo project (version 2019.2.619) with this example and it appears to be working properly at my end. The first grid's column is hidden when I click on the button "Go". 

Please feel free to modify the attached demo project with the behavior you are experiencing and/or share the current grid's configuration.

I look forward to your reply.

 

Best, Mihaela Lukanova Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Blake
Top achievements
Rank 1
commented on 29 Apr 2021, 10:51 PM

Thanks for the reply. You are right about our extensions. I am new to the project as well as to Kendo (obviously).

Fortunately, I stumbled on this in the process of making a sample project for you:

https://docs.telerik.com/aspnet-core/api/Kendo.Mvc.UI.Fluent/GridBuilder#columnmenusystemactionkendomvcuifluentgridcolumnmenusettingsbuildert

It runs without JavaScript errors and is closer to what our Product Owner wants, anyway. Thanks again.
Nikolay
Telerik team
commented on 04 May 2021, 10:58 AM

Hello Blake,

My name is Nikolay and I am replying as my colleague Mihaela is out of the office.

I am happy to hear you managed to resolve the situation.

Please let us know if anything new arises.

Tags
Grid
Asked by
Blake
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or