Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Add behavior to component (grid) with angular directives #405

Open
mikehaas763 opened this issue Dec 11, 2015 · 1 comment
Open

Add behavior to component (grid) with angular directives #405

mikehaas763 opened this issue Dec 11, 2015 · 1 comment

Comments

@mikehaas763
Copy link

I'm trying to supplement a kendo component by creating my own directive that I can add as an attribute to the kendo directive. In my situation I'd like to add my own directive to the kendo-grid element I'm using. The hard part is finding a proper way to get a reference to the grid in that directive or its element. All I'm trying to do is add a click handler to the header of the expand collapse detail column so that I can implement a "expand all" feature.

The most straight forward way would be if I could hook into some event from the $element that angular passes into my directive which fires once the grid is rendered.

Hopefully this snippet explains what I'm trying to do:

    angular.module('mod')
        .directive('kendoExpandAll', kendoExpandAll);

    function kendoExpandAll() {
        return {
            scope: {},
            controller: KendoExpandAll,
            controllerAs: 'KendoExpandAll',
            bindToController: true,
        };
    }

    KendoExpandAll.$inject = ['$element'];
    function KendoExpandAll($element) {
            // somehow get an instance of the kendo grid that this directive has been added to
            var expandHeaderJqElement = kendoGridInstance.thead.find('.k-hierarchy-cell.k-header');
            expandHeaderJqElement.on('click', toggleExpandAll.bind(kendoGridInstance));
    }
@leblancmeneses
Copy link

$element.data('kendoGrid') I have a util method to poll until data is available on .data('kendoGrid') or any kendo control.

 restrict: 'A',
//scope:{}
 controller: ...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants