I have an html page with two kendomultiselect controls initialized with a code like the following:
function msAssegnatariConoscenza_GetDataSource()
{
return new kendo.data.DataSource(
{
serverFiltering: true,
schema: {
data: function (response)
{
//...
return response;}
},
transport: {
read: {
url: "../Api/Assegnatari_SearchWithUO", //Assegnatari_Search
contentType: "application/json; charset=utf-8",
dataType: "json",
type: "POST"
},
parameterMap: function (data, type)
{
//...
return JSON.stringify(data);
}
}
}
);
}
function msAssegnatariConoscenzaInit(fIsReadOnly)
{
if (!datiSmistamento.AssConoscenza) datiSmistamento.AssConoscenza = [];
$("#field_AssConoscenza").kendoMultiSelect({
autoBind: false,
dataTextField: "Nome",
dataValueField: "ID",
minLength: 3,
delay: 500,
height: 300,
headerTemplate: '...',
tagTemplate: '...',
itemTemplate: '...',
filtering: function (e)
{
if (!e.filter || !e.filter.value)
e.preventDefault();
},
dataSource: msAssegnatariConoscenza_GetDataSource() ,
value: null,
select: function (e)
{
var dataItem = this.dataItem(e.item.index());
return selectAssegnatarioConoscenza($(this.element[0]).attr("id"), dataItem, e);
},
change: function (e) { return msAssegnatariConoscenza_changeEvent(this, e); }, //Fired when value changed by the user, not form code.
dataBound: function (e) { e.sender.listView.focusFirst(); return false; }
});
}
When I delete an element in one control, I have to add it to the other control.
On the change event of the first I set the new value of the second with the following code:
msAssegnatariConoscenza.value([]); msAssegnatariConoscenza.dataSource.data(datiSmistamento.AssConoscenza); msAssegnatariConoscenza.value(datiSmistamento.AssConoscenza.map(avmAss => avmAss.ID));
Can anyone tell me what I have done wrong?
Hi Giovanni,
Linked here you will find a small example based on the provided requirements - https://dojo.telerik.com/IngElumm. The second MultiSelect has initial value. Once a value in the first MultiSelect has been deselected, it is also removed from the dataSoruce of the first MultiSelect and added to the second. Could you please take a look at the example and try to replicate the behvaior the way it is on your side and send it back?
This will give us the possibility to troubleshoot and get a better idea of the caus of the issue.
Looking forward to your reply.
Regards,
Neli
The problem occurs in a slightly more complex context than the one in the example https://dojo.telerik.com/IngElumm.
I think the problem is related to the following code:
filtering: function (e) { if (!e.filter || !e.filter.value) e.preventDefault(); }
and the presence of server calls (Api call)
transport: { read: { url: "../Api/Assegnatari_SearchWithUO", //Assegnatari_Search ...
Can I send you a small Visual Studio Asp Mvc project?
If yes, can you tell me how I can send it to you?
Regards.
Giovanni
Hi Giovanni,
I see you have an active license. You could open a support ticket and send the runnable isolated sample there, thus the sample application will not be public.
Regards,
Neli