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

TreeView custom directices

2 Answers 54 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
afruiz
Top achievements
Rank 1
afruiz asked on 09 Jul 2018, 07:22 AM

Hello,

I need to use custom directives for manage checkedChange behavior.

Firstly I tried:

 <kendo-treeview [nodes]="model.Nodes"
                    textField="TextField"
                    kendoTreeViewExpandable
                    [expandBy]="model.ExpandBy"
                    [(expandedKeys)]="model.ExpandedKeys"
                    [hasChildren]="model.HasChildren"
                    [children]="model.Children"

                    [kendoTreeViewCheckable]="model.CheckableSettings"
                    [(checkedKeys)]="model.CheckedKeys"
                    [checkBy]="model.CheckBy"
                    [isChecked]="model.IsChecked"
                    (checkedChange)="checkMultiple($event)"
    </kendo-treeview>

but fires my event, and then the default event also. So checkMultiple was executed 2 times, so I could't check items. I thought that this way ignore the default event.

For this reason I decided to use my own custom directives, to overwrite all:

<kendo-treeview [nodes]="treeView.Nodes"
                    textField="TextField"
                    kendoTreeViewExpandable
                    [expandBy]="treeView.ExpandBy"
                    [(expandedKeys)]="treeView.ExpandedKeys"
                    [hasChildren]="treeView.HasChildren"
                    [children]="treeView.Children"

                customCheck
                    [(checkedKeys)]="treeView.CheckedKeys">
    </kendo-treeview>

2 Answers, 1 is accepted

Sort by
0
afruiz
Top achievements
Rank 1
answered on 09 Jul 2018, 07:31 AM

I'm following your example(Custom multi-check Directive):

https://www.telerik.com/kendo-angular-ui/components/treeview/checkboxes/

but treeview doesn'r use my own directives. I realize that never run the the customDirective contructor.

I made the customDirective imports in app.module too.

I prefer resolve with the first solution, but i would like to known why the customDirective doesnt work

0
Georgi Krustev
Telerik team
answered on 10 Jul 2018, 07:35 AM
Hi afruiz,

The `kendoTreeViewCheckable` will wire the checkedChange event of the TreeView and will perform its built-in check logic. If you would like to provide a custom implementation, then the correct approach is to provide a custom checkable directive, like you've already noticed.

The custom directive is not initialized if the directive is not declared in the `declarations` section of the module. The other option is if the compiler cannot match the directive to the binding applied to the treeview. For the former ensure that the custom directive is added to the module. For the latter, ensure that the naming of the custom directive is correct.

Here is a simple plunker that demonstrates a custom directive usage with the same naming.

https://next.plnkr.co/edit/ONlw7vI4piPHuQN5

Please modify the example in order to demonstrate the issue if it still persists. This will help us to observe the case locally and find a proper solution faster.

Regards,
Georgi Krustev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
afruiz
Top achievements
Rank 1
Answers by
afruiz
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or