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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

drop down datamanager with parameters error

Thread ID:

Created:

Updated:

Platform:

Replies:

128891 Feb 14,2017 03:52 PM UTC Mar 6,2017 12:36 PM UTC ASP.NET MVC 6
loading
Tags: DropDownList
Manolo
Asked On February 14, 2017 03:52 PM UTC

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?

Prince Oliver [Syncfusion]
Replied On 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 


Manolo
Replied On 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

Prince Oliver [Syncfusion]
Replied On 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 


Prince Oliver [Syncfusion]
Replied On 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 


Manolo
Replied On March 3, 2017 08:07 AM UTC

Thanks!

Prince Oliver [Syncfusion]
Replied On March 6, 2017 12:36 PM UTC

Hi Manolo, 
  
Most Welcome. 
  
Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;