We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

drop down datamanager with parameters error

Hi,

I've this page:



When I click on "Validar" button, I show a modal form, and this modal form has a drop downlist. When I click in any button the first time, I've get an error. After, works perfect.



My Javascript code:

 function onClick(args) {
        var grid = $("#gridPendientesValidar").ejGrid("instance");
        var index = this.element.closest("tr").index();
        var record = grid.getCurrentViewData()[index];

        $(".modal-body .hiddenId").val(record["ID"]);
        $(".modal-body .hiddenIdTipologia").val(record["IdTipologia"]);
        $(".modal-body .hiddenUserNameRemitente").val(record["RemitenteEnviado"]);

        var idTipologia = parseInt(record["IdTipologia"]);

        var dataManagerSubtipologias = ej.DataManager({
            url: baseUrl + "Notificaciones/GetSubtipologias",
            adaptor: new ej.UrlAdaptor(),           
        });
        $("#ddlSubtipologia").ejDropDownList({
            dataSource: dataManagerSubtipologias,
            query: new ej.Query().addParams("idTipologia", idTipologia),
            fields: { text: "Nombre", value: "IdSubtipologia" },
        });

       $("#modalValidacion").modal();

    }

My controller code

 public JsonResult GetSubtipologias(int idTipologia)
        {
            ////if (idTipologia == null)
            ////    return null;
            var datos = _repositorio.GetSubTipologias((int)idTipologia);
            return Json(datos);
        }

If i set as parameter int? the first time not work



This function is exec two times



The drop down is empty



After fist time, if I click on any button, it works fine



Any idea?

6 Replies

PO Prince Oliver Syncfusion Team February 15, 2017 04:56 PM UTC

Hi Manolo,  

Thanks for contacting Syncfusion support.  

We tried to replicate your scenario to reproduce the issue at our end. We were unable to reproduce the error. We have attached a working sample for rendering dropdownlist inside a modal dialog on button from the code you shared.  


Regards,  
Prince 



MA Manolo February 28, 2017 11:09 AM UTC

I'm sorry for the delay.

I still have the problem, but now, I attach an example code.

When you click on details the first time, the dropdownlist is not loaded, but if you close the modal form and reopen, the dorpdown fill correct

Attachment: DataManager_387cfb50.zip


PO Prince Oliver Syncfusion Team March 2, 2017 07:16 AM UTC

Hi Manolo, 

Thank you for your update. 

We checked the sample you shared, it seems that you have used Razor code to initialize dropdown and again in button click method you are initializing dropdown to bind data in Javascript. This caused a POST request for data fetch twice and during first time it sends an empty params, which causes a POST fail in our controller. We suggest you to render the dropdown list once. Kindly have a look at the following code snippet. 

<div class="modal-body"> 
    <div class="container"> 
        <div class="col-md-4"> 
            <h5>Subtipologia</h5> 
            @*@Html.EJ().DropDownList("ddlShipCity").Width("100%")*@ //instead of using razor code use javascript 
            <input type="text" id="ddlShipCity" /> 
        </div> 
        <div class="col-md-4"></div> 
    </div> 
</div> 

We have attached the modified sample, refer to the following link for the sample: 

Regards, 
Prince 



PO Prince Oliver Syncfusion Team March 2, 2017 07:16 AM UTC

Hi Manolo, 

Thank you for your update. 

We checked the sample you shared, it seems that you have used Razor code to initialize dropdown and again in button click method you are initializing dropdown to bind data in Javascript. This caused a POST request for data fetch twice and during first time it sends an empty params, which causes a POST fail in our controller. We suggest you to render the dropdown list once. Kindly have a look at the following code snippet. 

<div class="modal-body"> 
    <div class="container"> 
        <div class="col-md-4"> 
            <h5>Subtipologia</h5> 
            @*@Html.EJ().DropDownList("ddlShipCity").Width("100%")*@ //instead of using razor code use javascript 
            <input type="text" id="ddlShipCity" /> 
        </div> 
        <div class="col-md-4"></div> 
    </div> 
</div> 

We have attached the modified sample, refer to the following link for the sample: 

Regards, 
Prince 



MA Manolo March 3, 2017 08:07 AM UTC

Thanks!


PO Prince Oliver Syncfusion Team March 6, 2017 12:36 PM UTC

Hi Manolo, 
  
Most Welcome. 
  
Regards, 
Prince 


Loader.
Live Chat Icon For mobile
Up arrow icon