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

Treelist createChild click event does not work

3 Answers 456 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
jamana
Top achievements
Rank 1
Veteran
jamana asked on 28 Apr 2020, 02:30 PM

Hi,

I am trying to fire an event on "createChild" click. Below is my code sample.

I have an "Actions" column and there are 2 commands (Add Child and Delete) specified under this column. I want to call a javascript function when user clicks on "add child" image to set "id" to the newly created row. But the "createChild" function never gets executed. Is there something I am doing wrong here?  

columns : [
        {
title : "Actions", 
headerAttributes : {
style : "text-align:center;"
},
command : [
{
name : "createChild",
text : " ",
className : "btn-details",
imageClass : "fas fa-folder-plus fa-lg",
click : createChild
},
{
name : "destroy",
text : " ",
className : "btn-details",
imageClass : "icon icon-delete"
}],
width : 120
},

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 30 Apr 2020, 11:46 AM

Hello Jamana,

The click function is never executed as the name specified is "createChild". "createChild" is a reserved keyword for the built-in command creating a new child. If you would like to have the click function executed on a custom command simply set a name for the command that does not invoke an internal command, for example:

{ command : [
          {
            name : "createRowChild",
            text : "Create",
            className : "btn-details",
            imageClass : "fas fa-folder-plus fa-lg",
            click : createChild
          },

This is demonstrated in the following Dojo demo: 

Let me know if you have any questions.

Regards,
Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
jamana
Top achievements
Rank 1
Veteran
answered on 30 Apr 2020, 01:19 PM

Thanks Nikolay.

This change is firing the event. But unfortunately it is not adding a creating a child in the treelist as we have renamed from "createChild" to "createRowChild".

My requirement is to generate and assign an "id" dynamically for the newly created child record. This will help me in creating a one more new child record under the child recording created earlier.

I have to follow this approach to address the below issues mentioned in the previous post.

"When i created a child item for first level all is OK.
But when i add child item for before added item i'm still got freezed browser window."

https://www.telerik.com/forums/treelist-add-sub-item

Please let me know if this issues has been fixed or any workaround?

Thanks in advance,

Ramesh

0
Nikolay
Telerik team
answered on 04 May 2020, 12:01 PM

Hello Jamana,

Thank you for clarifying the case. 

I would suggest in the beforeEdit event handler to execute the logic after checking if the node has parents. The parentNode method can be used where null is returned in case if the node is a root node or does not have a parent.

Let me know if this helps.

Regards,
Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
TreeList
Asked by
jamana
Top achievements
Rank 1
Veteran
Answers by
Nikolay
Telerik team
jamana
Top achievements
Rank 1
Veteran
Share this question
or