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

MVC Wrappers : Foreign Key Column With Nullable Int Shows Blank Cells

3 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Evan
Top achievements
Rank 1
Evan asked on 20 Apr 2015, 08:05 PM

I still struggle continually with this issue.  If I use a nullable int on my model and use .ForeignKeyFor in my .cshtml, then when I select the first item in the list, it goes blank. I've added .ValuePrimitive(true) to my GridForeignKey.cshtml editor template, but this is still a problem.  Also, I think it's not unreasonable to expect if you add a row to the grid that it would default the value to null and let you select the first item in the list.  I don't think anything I've tried has let me do this.  The best I've been able to do is create an actual item for null with a value of 0 or something and then code it on the server side to treat 0 as null.  I don't feel like this is a great solution.  Anyone had better luck that me?  Telerik do you have a recommendation or an example?

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 23 Apr 2015, 06:50 AM
Hi,

Please accept my apologies for the delayed response.
This problem appears to be fixed in the internal builds. Can you please try upgrading to see if this helps?

You can also set an option label if you want to be able to select null value after editing:
Html.Kendo().DropDownListFor(m => m)    
    .BindTo((SelectList)ViewData[ViewData.TemplateInfo.GetFullHtmlFieldName("") + "_Data"])
    .OptionLabel(" ")
    .ValuePrimitive(true)


I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Steven
Top achievements
Rank 1
answered on 10 Mar 2016, 09:09 PM
I have the same issue. I wish they would resolve this.
0
Georgi Krustev
Telerik team
answered on 15 Mar 2016, 08:18 AM
Hello Casey,

Could you upgrade to the latest internal build of Kendo UI / UI for ASP.NET MVC?

If the problem still persists, please send us a repro demo that demonstrates the issue.

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
Grid
Asked by
Evan
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Steven
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or