This is a migrated thread and some comments may be shown as answers.

Selected Item bug in 2013.1?

12 Answers 120 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Ely
Top achievements
Rank 1
Ely asked on 04 Apr 2013, 10:08 PM
Hello,

After upgrading from 2013.1 from 2012.3, when I bind a source to a drop down list, there is not a selected item in the list anymore.  I created two js fiddles which show this.

This first one is using 2012.3, note that the drop down list has Item1 selected by default:
http://jsfiddle.net/m4LPB/2/

This one is using 2013.1, note that the drop down list does NOT have an item selected:
http://jsfiddle.net/2FHsV/1/

Also, it appears that 2013.1 ignores anything I add to a data-index attribute on the select tag, where it should set the default item.

Thanks

12 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 08 Apr 2013, 03:30 PM
Hello Ely,

 
We introduced some improvements/bug fixes releted to the MVVM binding and cascading functionality of the DropDownList widget. The problem in this case is related to а specific SELECT behavior, which does not select an item when options are added manually. Currently, you can overcome this issue using the data-value attribute like this:

<select ... data-value="Item 1">
We will address this problem in the next internal build.

I updated your Telerik points, because of the involvement.

Regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 01 May 2013, 01:37 PM
We are experiencing the same problem, but we are using MVC Razor.  It is not setting the correct value when the model binds.

This is the code:
@Html.Kendo().DropDownListFor(model => model.IsActive)
                       .DataTextField("Text")
                       .DataValueField("Value")
                       .BindTo(new[]
                          {
                              new SelectListItem { Text = "Yes", Value = "True"  },
                              new SelectListItem { Text = "No", Value = "False" }
                          });
This worked in 2012.3.1315 but not in 2013.1.319.
What do I need to do to get this working again?
0
Mike
Top achievements
Rank 1
answered on 01 May 2013, 03:44 PM
If I move the list data out of the BindTo and into the DataSource Read event using a Controller Action, everything works fine. For example:
@Html.Kendo()
  .DropDownListFor(m => m.IsActive)
  .DataTextField("Text")
  .DataValueField("Value")
  .DataSource(source => source.Read("GetYesNoValues", "Kendo"))

Thanks,
Mike
0
Georgi Krustev
Telerik team
answered on 02 May 2013, 07:49 AM
Hello Mike,

 
I will suggest you download the latest internal build of Kendo UI and give it a try. Let me know if the problem still persists.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mike
Top achievements
Rank 1
answered on 02 May 2013, 01:02 PM
Georgi,
 
Is there a way that I can just install the DropDownList component of the internal build?

Thanks,
Mike
0
Alex Gyoshev
Telerik team
answered on 03 May 2013, 03:06 PM
Hello Mike,

Upgrading only part of the release is not supported, as it may trigger unexpected issues (i.e. if a bug fix spans across multiple files). You can use the Visual Studio extension for Kendo UI to make the upgrade process fast and simple.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bimar
Top achievements
Rank 1
answered on 22 Jul 2013, 06:08 AM
Hello Alex,
Is this bug fixed?

I tried 2013.2.716, but still it doesn't work.

Best regards
Serkan
0
Georgi Krustev
Telerik team
answered on 24 Jul 2013, 07:30 AM
Hello Serkan,

 
I believe that the problem was addressed in the official release of Kendo UI. Check this jsBin demo for reference.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bimar
Top achievements
Rank 1
answered on 25 Jul 2013, 12:45 PM
Dear Georgi,
I am uploading a sample project to show the bug.
Firstly please click "Normal" link. You will see a selected item called "Serkan".
After that please click "Bug" link. You will see no item is going to be selected in dropdownlist.

Best regards
Serkan
0
Georgi Krustev
Telerik team
answered on 26 Jul 2013, 08:39 AM
Hello Serkan,

 
Thank you for the test project. I noticed GetYesNoValues Action method returns values which has lower case letters. On the other hand bool variable in .NET is searialized in "PascalCase". In other words the widget has values with "true"/"false" values and its value is "True", which are not equal. In order to address this you will need to fix the casing of GetYesNoValues values:

public ActionResult GetYesNoValues()
        {
            var list = new List<SelectListItem>() {
                      new SelectListItem() {
                          Text = "Yes",
                          Value = "True"
                      },
                      new SelectListItem() {
                          Text = "No",
                          Value = "False"
                      }};
            return Json(list, JsonRequestBehavior.AllowGet);
        }

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Bimar
Top achievements
Rank 1
answered on 26 Jul 2013, 11:48 AM
Hi Georgi,
Thanks for your quick reply.
I attached another sample project.
Please click Bug link and click edit button in grid.
You will see dropdownlist which doesn't set selected value.

Regards
Serkan
0
Georgi Krustev
Telerik team
answered on 29 Jul 2013, 11:52 AM
Hello again Serkan,

 
Thank you for the test project. The DropDownList does not select correct value, because the Grid widget is bound to a list of JSON where boolean properties are serialized as boolean and not like a string. On the other hand, the DropDownList widget is bound to a list of SelectListItem where values are strings. As you probably know "True"/"true" is different than true. You can handle this difference wiring the edit event of the grid and manually set the widget. Other option is to use custom model instead of SelectListItem, which will be serialized as the Grid's data. Check the attached achieve for more information about the first approach.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Ely
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Mike
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Bimar
Top achievements
Rank 1
Share this question
or