BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
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,
<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> |
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);
} |
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
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
Hello Deepak,
Thank you for your efforts in solving my problem. I actually found yesterday a solution for that.
Regards,
Alexandre