kendomultiselect value setting not rendered

0 Answers 17 Views
Data Source MultiSelect
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Giovanni asked on 10 Jan 2025, 01:50 PM | edited on 10 Jan 2025, 01:50 PM

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));
So if I choose a new value in the second control typing chars and choosing from list, and then delete one on the first control, when I programmatically set the new value of the second control it will not be updated.

 

Can anyone tell me what I have done wrong?

Neli
Telerik team
commented on 15 Jan 2025, 08:52 AM

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

Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
commented on 15 Jan 2025, 10:18 AM

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

Neli
Telerik team
commented on 20 Jan 2025, 09:19 AM

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

No answers yet. Maybe you can help?

Tags
Data Source MultiSelect
Asked by
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or