1
votes

Here my code to hide a column in kendo grid.

var grid = angular.element("#priceCardGrid").data("kendoGrid");
for (var i = 0; i < priceCardModalScope.priceCard.length; i++) {
    if (priceCardModalScope.priceCard[i].shouldAcceptQty == true) {
        grid.hideColumn(1);
    }
}

but it shows error like

Uncaught TypeError: Cannot read property 'hideColumn' of undefined

2
I don't have much idea about angularJS but could you please try with stackoverflow.com/questions/24238403/…Jayesh Goyani

2 Answers

0
votes

In your case I think you have a problem with angular.element(). You should do something like this(angular.element vs document.getElementById or jQuery selector with spin (busy) control):

angular.element( document.querySelector('#some-id'));

Hope this helps.

A recommendation I can give you when working with angular and kendo componentes, is to assign them to the scope. For example:

<div kendo-grid="ctrl.grid" class="table"
   k-data-source="ctrl.dataSource"
   k-options="ctrl.options">
</div>

Then youn could easily use: scrop.grid.hideColumn();

0
votes

The error indicates that the Grid instance does not exist (yet) or you are trying to retrieve it from the wrong element. If you are executing the provided code on page load, then move it to a kendoWidgetCreated or kendoRendered handler.

http://docs.telerik.com/kendo-ui/AngularJS/global-events