while page loads dropdown control shows selected value.

2 posts, 0 answers
  1. Vikas
    Vikas avatar
    2 posts
    Member since:
    Jan 2014

    Posted 11 Aug Link to this post

    Hi

    While page refreshes and reloads, DropDown list shows Drop Down's selected value in a textbox. Though Once page is loaded it is all fine. But for our purpose it is not desirable to show value that dropdown is binded to. If it had shown the selected text it would have been ok. We also don't want to hide the drop down untill page is ready and show it.

     I dont see it is a performance issue as well since i created a seperate view and had only dropdown control in the entire view. Have provided sample code that you can execute to test the behavior

    @model ViewModels.DdlVM

    @using (@Html.BeginForm())
    {
    @(Html.Kendo().DropDownListFor(m => m.ddlprop)
                                .DataTextField("Text")
                                .DataValueField("Value")
                                .BindTo(Model.ddlOptions )
                                )
    <input type="submit"
    value="save" />
    }

    namespace ViewModels
    {

      public class DdlVM
        {    public List<SelectListItem> ddlOptions { get; set; }

         public string ddlprop{ get; set; }

    }

    }

    controller

      public ActionResult ClickMe()
            {
                DdlVM testvm = new DdlVM();
                testvm.ddlOptions = new List<SelectListItem>();
                for (int i = 0; i < 100; i++)
                {
                    testvm.ddlOptions.Add(new SelectListItem()
                    {
                        Text = "TAB- " + i.ToString(),
                        Value = i.ToString()
                    });
                }
                return View("TestClickMe", testvm);
            }
            [HttpPost]
            public ActionResult ClickMe(DdlVM testvm)
            {
                testvm.DelimiterOptions = new List<SelectListItem>();
                for (int i = 0; i < 100; i++)
                {
                    testvm.ddlOptions.Add(new SelectListItem()
                    {
                        Text = "TAB- " + i.ToString(),
                        Value = i.ToString(),
                        Selected = testvm.ddlprop== i.ToString()
                    });
                }
                return View("TestClickMe", testvm);
                #endregion
            }

     

  2. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 15 Aug Link to this post

    Hello Vikas,

    Does the autoBind:false setting work for your case? It will not show the selected value until user opens the DropDownList. 

    Regards,
    Boyan Dimitrov
    Telerik by Progress
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  3. Kendo UI is VS 2017 Ready
Back to Top