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
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
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.
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
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.
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
Hi Veselin,
Is it possible to use this very example, but instead of SectionId for the Children i have a different ID name ?
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
Our thoughts here at Progress are with those affected by the outbreak.