Hello everyone,
the new kendoDropDownTree is excactly what a lot of us waited for since a long time. Now the question: Is it possible to have the selected items (using the "checkboxes: true" option) exportet on a POST request as an array? While the multiple select widget is rendered as an <select multiple="multiple"> the kendoDropDownTree is not, which is of course part of the problem...
5 Answers, 1 is accepted
Yes you are right - in such case we recommend posting the data manually after getting it from the widget by using its value method. Here is a sample code that I used at my side and I am attaching a sample runnable project in ASP NET Core :
$(
"#btnSave"
).on(
"click"
,
function
(e) {
var
multiselect = $(
'#dropdowntree'
).data(
'kendoDropDownTree'
);
var
dDTreeItems = JSON.parse(JSON.stringify(multiselect.value()));
debugger
var
data = {
DDTreeItems: dDTreeItems
};
$.ajax(
'/Home/Save'
, {
type:
'POST'
,
data: data,
dataType:
"json"
}).done(
function
() {
alert(
'done'
);
});
});
Hope this information will be helpful.
Regards,
Plamen
Progress Telerik
Hi everyone,
I'm sure there must have been some development in the meantime, so we don't have to hack our way out of here and can rely on real solutions instead. ;-) The code suggested above won't help unfortunately, because I'm implementing reusable widgets that are not aware of forms and save buttons. Is there any fancy way to have the widget behave like a regular multiple select widget and send its data on POST?
Bye,
Bo
The issue is not resolved yet but we will do our best to add it as soon as possible. Here is a github issue the you could follow. Please excuse us for the inconvenience caused by the issue.
Regards,
Plamen
Progress Telerik
Hi Plamen,
thank you very much for your answer. For now, I will copy the selected items into an additional input field myself, but doing so I encountered another problem, wich seems to be a bug as suggested here:
https://feedback.telerik.com/kendo-jquery-ui/1385117-in-dropdowntree-setting-value-is-doubling-the-values
On dataBound of the hierarchical data source, I try to add a freshly added data item like this:
var select=$("#%(id)s").data("select");
if ($.isNumeric(select)) {
var value=$("#%(id)s").data("kendoDropDownTree").value();
var select=parseInt(select)
if($.inArray(select,value)>=0) {
$("#%(id)s").data("select",undefined);
} else {
value.push(select);
$("#%(id)s").data("kendoDropDownTree").value(value);
$("#%(id)s").data("kendoDropDownTree").trigger("change");
};
};
The way it is implemented right now, I get buttons for all selected values, but only the button for the newly added item is working and checked in the dropDownTree. The values selected before do also show buttons, but you can't click x to remove/unselect. They are also not checked in the tree. Depending on where I set the value, I also had a case where the buttons double (half non-working, half fine). I assume, that this seems to be related to the bug mentioned above. Some problem with connecting the buttons to the reloaded datasource probably?
While loading on demand works fine, I was also wondering if it is possible to load the remaining (unloaded) data at once as soon filtering occurs. This makes sense, because otherwise you wont find the item you are looking for, so it should be a feature. There is a nice event for this (filtering), but changing loadOnDemand from true to false and resetting the datasource does not seem to work. Also a bug or a feature?
Thanks again,
Bo
In the issue that you linked if you set the values as numbers they are not duplicated as for example it is done in this dojo so you could try to workaround the issue by using such technique in your case too.
As for the filtering of large data structured - this is a very interesting problem to solve yet it is currently not supported by DropDownTree.
In such similar cases in other widgets, since we usually need to go to the server, we go for a server side filtering and try to return only the needed nodes. Server filtering for DropDownTree is in our to do list yet its not yet known when it will be added to the widget.
If you have further questions please let me know.
Regards,
Plamen
Progress Telerik