Trouble adding data source from object list in

Hello,


I am trying to fill the datasource property of a combobox control after an Ajax call. But I am getting an error of Maximum call stack size exceeded .

This is the control:

<ejs-combobox id="lstRequisitante" placeholder="Selecione um Requisitante..." allowFiltering="true" filterType="Contains" popupHeight="200px" width="100%" showClearButton="true" change="RequisitanteValueChange">

         <e-combobox-fields text="Requisitante" value="RequisitanteId"></e-combobox-fields>

</ejs-combobox>


This is a sample of the data it should be receiving:

[{ RequisitanteId: '8852c87d-90d8-4a16-8d13-08d97f8b08a4', Requisitante: 'Alexandre Delgado (p_7661) - (SEMOV)'},{ RequisitanteId: '6b5d6bd9-68d9-457d-ce5a-08d99f8ffe50', Requisitante: 'Shaiana Campelo (7602) - (SECAD)'}]


This is the Ajax call:

            $.ajax({

                url: "/Viagens/Upsert?handler=AJAXPreencheListaRequisitantes",

                method: "GET",

                datatype: "json",

                success: function (res) {

                    document.getElementById("lstRequisitante").ej2_instances[0].dataSource = res;

                }

            })

If I hard code the data using:

document.getElementById("lstRequisitante").ej2_instances[0].dataSource = [{ RequisitanteId: '8852c87d-90d8-4a16-8d13-08d97f8b08a4', Requisitante: 'Alexandre Delgado (p_7661) - (SEMOV)'}];

It works and populate the list. But when coming from the Ajax response, it generates an error. I saw in the console that the response content is exactly what I hardcoded. So, I don't know where the is the error in the code.

I would appreciate any help on the subject.

Regards,



10 Replies

DR Deepak Ramakrishnan Syncfusion Team November 23, 2021 06:55 PM UTC

Hi Alexandre, 
 
Greetings from Syncfusion support. 
 
We are currently working on your requirement. we will further validate and update the details in two business days (29th,November 2021).We appreciate your patience until then. 
 
 
Thanks, 
Deepak R. 



DR Deepak Ramakrishnan Syncfusion Team November 24, 2021 11:37 AM UTC

Hi Alexandre,  
  
Sorry for the miscommunication caused. 
  
We will update the details within two business days (26th,November 2021). 
  
  
Thanks,  
Deepak R.  
 



DR Deepak Ramakrishnan Syncfusion Team November 29, 2021 03:58 PM UTC

Hi Alexandre, 
 
Thanks for your patience. 
 
We have validated the reported issue with provided details .And we suggest you to use custom adapter instead of fetching the data using the ajax, As it provides the built-in support for the same functionality. We have also attached sample for your reference . 
 
[index.cshtml] 
<ejs-combobox id="country" placeholder="Select a Country"> 
            <e-data-manager adaptor="UrlAdaptor" url="/Home/UrlDatasource" crossDomain="true"></e-data-manager> 
            <e-combobox-fields value="ShipCountry"></e-combobox-fields> 
        </ejs-combobox> 
 
[HomeController.cs] 
public ActionResult UrlDatasource([FromBody] Data dm) 
        { 
            var val = OrdersDetails.GetAllRecords(); 
            var Data = val.ToList(); 
            var count = val.Count(); 
            if (dm.where != null) 
            { 
                Data = (from cust in Data 
                        where cust.ShipCountry.ToLower().StartsWith(dm.@where[0].value.ToString()) 
                        select cust).ToList(); 
            } 
            if (dm.take != 0) 
                Data = Data.Take(dm.take).ToList(); 
            return Json(Data); 
        } 
 
 
 
 
If this does not meets your requirement kndly provide the following details to proceed further in our end. 
 
1.In which event of the component , you have handled the ajax request. 
2.Simple runnable sample or modify the provided sample as per your requirement. 
 
 
Thanks, 
Deepak R. 



AL Alexandre November 29, 2021 06:00 PM UTC

Hello Deepak,


Unfortunately the example you provided does not apply to my situation. To explain the question in more details, I have this dropdown list in a page, where there is a button that opens a modal form to add new itens to that list. Upon closing the form, I have the Ajax call to refill the list with the new data. So, the Ajax call does not happen in any event of the control. In fact, the dropdown list only gets "refreshed" with the Ajax call. And that is where I am having trouble.


I am showing in the image below the situation I described above:



I have the dropdown list "Requisitante" which has a button on its rigth side, that opens the modal form. When the user adds a new Requisitante, is when I make the Ajax call to refill the list. The code for all that was provided in my first message.


Regards,


Al



DR Deepak Ramakrishnan Syncfusion Team November 30, 2021 06:20 PM UTC

Hi Alexandre, 
 
Thanks for the update. 
 
We have analyzed the details provided from your end and we suspect that you are trying to add the item to the datasource from the fields dynamically added in the components inside the modal using ajax call . We request you confirm this as your exact requirement in your end. Also kindly provide the simple runnable sample or modify the provided sample as per your requirement which reproduces the issue . So that we can analyze further and provide you the better solution. 
 
Thanks, 
Deepak R. 



AL Alexandre December 1, 2021 02:32 PM UTC

Hello Deepak,


I confirm that. I am trying to update the combobox datasource from within the Ajax call.


I have tried to modify your sample to reproduce the situation in question, but since I use Razor Pages in my project I had to start a new on from the ground up. Now I am having trouble to make the combobox reach the datasource in the Controller. I keep getting a 404 error.


I am sending the project attached to this reply, so that you can help make this connection. Once I have that, I can modify the code to reproduce what I am trying to do.


Regards,


Alexandre


Attachment: Syncfusion_AJAX_63fb8115.rar


DR Deepak Ramakrishnan Syncfusion Team December 2, 2021 03:47 PM UTC

Hi Alexandre, 
 
Thanks for providing required details. 
 
We will validate and update the further details within two business days(6th,December 2021).We appreciate your patience until then. 


 
Thanks, 
Deepak R. 



DR Deepak Ramakrishnan Syncfusion Team December 6, 2021 05:55 PM UTC

Hi Alexandre, 
 
Thanks for your patience. 
 
We are still working on your requirement .We will update the details within two business days (8th,December 2021).We appreciate your patience until then. 
 
 
Thanks, 
Deepak R.




AL Alexandre December 7, 2021 08:53 AM UTC

Hello Deepak,


Thank you for your efforts in solving my problem. I actually found yesterday a solution for that.


Regards,


Alexandre



DR Deepak Ramakrishnan Syncfusion Team December 8, 2021 12:41 PM UTC

Hi Alexandre, 
 
Thanks for your update. 
 
We are glad that the issue has been resolved at your end. We will always happy to assist you. 
 
 
Thanks, 
Deepak R. 


Loader.
Up arrow icon