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

dropdownlist with server binding is invisible when we have a default value, and visible when no value is set.

4 Answers 258 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Rene
Top achievements
Rank 1
Rene asked on 21 Oct 2013, 09:22 AM
Hi there.

I have several dropdownlist boxes, and each box is populated serverside
<BR><div style="position:absolute; @(item.GetDataSizePos(true));
margin-top:0px;"><BR>
@Html.Kendo().DropDownList().Name(item.le.FieldId).BindTo(CaretakerPortal.App_Start.CaretakerHelpers.CreateSelectList(item.le.DropDownItems,
item.datavalue.IntValue.ToString())).Enable(true).OptionLabel("Vælg fra
listen").HtmlAttributes(new { @style = "width: 100%; height: 100%;" })<BR>
</div>
The CreateSelectList function returns a List<SelectListItem>
When the returned List<SelectListItem> got a default value (Selected=true), the dropdownlist is not visible, if there is not selected value, then the dropdownlist is visible.
In firebird developer screen, i can see it sets visibility: hidden when i got a value, and its not there when i dont have a value.
When i have a value for a dropdownlist - html code:

<span class="k-widget k-dropdown k-header" style="width: 100%;
height:
100%;" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="aktivitet_aprioritet_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="aktivitet_aprioritet_option_selected"><BR><span class="k-dropdown-wrap
k-state-default" unselectable="on" style="visibility: hidden; color:
rgb(153, 153,
153);"><input id="aktivitet_aprioritet" class="valid" type="text" value="A" style="width:
100%; height: 100%; display:
none;" name="aktivitet.aprioritet" data-role="dropdownlist"><BR></span>
Note the second <span>
And here is the html code when i dont have a value:
<span class="k-widget k-dropdown k-header" style="width: 100%;
height:
100%;" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="aktivitet_ansvarlig_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="aktivitet_ansvarlig_option_selected"><BR><span class="k-dropdown-wrap
k-state-default" unselectable="on" style="color: rgb(153, 153,
153);"><input id="aktivitet_ansvarlig" class="valid" type="text" style="width:
100%; height: 100%; display:
none;" name="aktivitet.ansvarlig" data-role="dropdownlist"><BR></span>
Im a missing something obvious?
Right now i will just create a standard combobox in html to get along, but would prefer to use kendo objects.
Thanks in advance
 - René





4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 Oct 2013, 10:05 AM
Hello Rene,

 
I prepared a simple test project in my attempt to replicate this issue, but to no avail. Could you please modify it in order to reproduce the problem? Thus I will be able to review the code locally and advice you further.

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
Rene
Top achievements
Rank 1
answered on 24 Oct 2013, 06:03 AM
Hi there

Thanks for the reply and the test-project. Ill look into this when i get a minute or 2 :-)
The only special thing from my setup is i have several dropdownlists - all using datasources with data loaded with the page, instead of from a Ajax call.

 - René
0
Georgi Krustev
Telerik team
answered on 28 Oct 2013, 07:40 AM
Hello Rene,

 
The attached test project also uses local data binding. Let me know what your findings are.

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
Rene
Top achievements
Rank 1
answered on 13 Nov 2013, 09:49 AM
Just an update.
I tried to copy more and more of the code from our source to your demo project.
I copied the site.css, and tried all kendo js / css just to make sure.
We do have a pretty dynamic setup where most Windows are created with dynamic fields, and we design the layout from another application (x, y, Width and height of each field). Even dropdown values are generated else where. This make it pretty difficult to copy all the logic.

The main problem was with a combobox where i generate the List<SelectListItem> from a static function
public static List<SelectListItem> CreateSelectList(String dropDownItems, String selectedValue)
I add the SelectListItem with the last argument
rVal.Add(new SelectListItem(){Text=keyValue[0], Value=keyValue[1], Selected=(selectedValue.Equals(keyValue[1]))});
I checked the code, and only one selectlistitem is marked at Selected = true.

Now i tried another approach, where i use the .SelectedIndex(x) on the combobox instead - and this Works.!
So for now , this is working and i can create a function to find the index number, and i tried with -1 to see if that Works like expected (none selected).
So thanks for the effort, im on track Again..

 - René
Tags
DropDownList
Asked by
Rene
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Rene
Top achievements
Rank 1
Share this question
or