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

kendo dropdowntree in a grid as editor doesn't trigger change

7 Answers 777 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
dominic
Top achievements
Rank 1
dominic asked on 05 Sep 2019, 12:12 PM

Hi,

I have a grid that can be modified incell and in one of my cell, I have an editor that creates a dropdowntree. When i want to select an element of the dropdowntree it trigger the select event but not the change event and doesn't go in the save of my grid.

 

The dojo link will show you the problem

https://dojo.telerik.com/uSULOkUc

 

Please let me know if you have any fix for this.

Thanks.

7 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 06 Sep 2019, 08:37 AM
Hello,

The change was not triggered because of the  e.preventDefault(); line in the select event - once | commented it the change was triggered again - https://dojo.telerik.com/@zdravkov/IwaFIjag.

This is an expected behavior - if we prevent the selection we don't expect a change to happen.

Regards,
Plamen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
dominic
Top achievements
Rank 1
answered on 09 Sep 2019, 12:53 PM

Hello Plamen,

You are right it always goes in this condition because of a mistake I made. After the correction I have another problem, now I can select but the first time it doesn't trigger the change and the save of my grid. 

Here is the example https://dojo.telerik.com/ipEzEJoh

if you change the  section and you select one node it will only trigger the select of the dropdowntree. If you select another time it will trigger everything(select change and save).

Thanks.

0
Accepted
Veselin Tsvetanov
Telerik team
answered on 11 Sep 2019, 09:02 AM

Hi Dominic,

Here you will find a modified version of the sample discussed, which fires all expected events upon DropDownTree selection change. Here are the important bits that I have changed:

- As far as I can understand, you would like to mark those items in the Grid that do not have a sectionId with the following string: "00000000-0000-0000-0000-000000000000". To do that, I would suggest you assign a null value to that field and use a column template to render the required string:

data: [{
  "ReceptionProductid":"e611c4dc-2947-479b-80c3-7d99436301e1",
  "receptionID":"14ba5b21-fe00-4588-b9d8-81b875b9fab3",
  "productId":"56666007-047f-4257-81f8-e254e68c5a9c",
  "sectionId": null
}],

and:

{
  field: "sectionId",
  title: "Section",
  editor: SectionDropDownEditor,
  template: '#if (sectionId !== null) { # #= sectionId # # } else { # 00000000-0000-0000-0000-000000000000 # } #',
  width: 200
}

- I have added a schema configuration for the Grid DataSource. Grid wich allows editing should always specify the id of its items:

schema: {
model: {
  	id: "ReceptionProductid"
 }
}

- I have removed the redundant fields and id configuration from the DropDownTree DataSource:

let warehouseDS = new kendo.data.HierarchicalDataSource({
  data: warehouseData(),
  schema: {
    model: {
      children:{
        schema: {
          data: "warehouseSectionList",
          model: {
            children: "sectionChildrenList"
          }
        }
      }
    },
  },
});

- I have added the valuePrimitive: true, configuration to the DropDownTree. Also, I have removed the redundant value: configuration as it will be retrieved from the binding:

$("<input data-bind='value:sectionId' />")
  .attr("id", "ReceptionSectionddl")
  .appendTo(container)
  .kendoDropDownTree({
  dataSource: warehouseDS,
  dataTextField: ["WarehouseName", "SectionName"],
  dataValueField: "SectionId",
  valuePrimitive: true,
...

- I have added a SectionId field to the root item in the DropDownTree DataSource, as that field is specified as a dataValueField (see above):

function warehouseData(){
  return [{
    "SectionId": "test",
    "WarehouseId":"57176dad-50bc-41bb-a508-049146d59973",
    "WarehouseName":"Secondary",
...

Regards,
Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
dominic
Top achievements
Rank 1
answered on 11 Sep 2019, 01:20 PM

Hi Veselin,

removing the default value and setting the ID to null works! Now it goes into the change and save event.

Will it be possible in future versions to use the default value in dropdowntree?

Thank you for your help.

 

0
Veselin Tsvetanov
Telerik team
answered on 13 Sep 2019, 08:04 AM

Hello Dominic,

I am happy to hear that you have resolved the issue faced.

As per the default value in the DropDownTree, I believe that the placeholder configuration option would allow you to achieve the desired. Here is a modified Dojo sample using the above configuration.

Regards,
Veselin Tsvetanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
EMMANUEL
Top achievements
Rank 1
answered on 02 Jun 2020, 01:19 AM

Hi Veselin,

Is it possible to use this very example, but instead of SectionId for the Children i have a different ID name ?

0
Veselin Tsvetanov
Telerik team
answered on 03 Jun 2020, 10:10 AM

Hello Emmanuel,

You could define the custom editor for whichever field suits your needs. In case you would like to populate the DropDownTree with heterogeneous data (the items will use different fields for their ID), I am afraid that it won't be possible. The dataValueField in the DropDownTree should point to the same field for all its items.

Regards,
Veselin Tsvetanov
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
DropDownTree
Asked by
dominic
Top achievements
Rank 1
Answers by
Plamen
Telerik team
dominic
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
EMMANUEL
Top achievements
Rank 1
Share this question
or