One of the fields has a dropdown list using the OptionLabel for an editor template (see Image1). When creating a record on the grid, selecting an option other than the OptionLabel option save fine (see Image2).
When updating the record and selecting the OptionLabel option, everything saves fine (see Image3).
When updating again, all of the options save as [option Option] even though the dropdown list displays correctly (see Image4).
The easiest way to see this is by using the PopUp edit option and never refreshing the page.
7 Answers, 1 is accepted
I would suggest to try setting the ValuePrimitive option of the DropDownList to true:
@(Html.Kendo().DropDownList()
.Name(
"SomeName"
)
.ValuePrimitive(
true
)
Kind Regards,
Vladimir Iliev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
I would suggest to try setting the ValuePrimitive option of the DropDownList to true:
@(Html.Kendo().DropDownList()
.Name(
"SomeName"
)
.ValuePrimitive(
true
)
Kind Regards,
Vladimir Iliev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
This has not worked for me. Any other suggestions?
From the provided information it's not clear for us what is the exact setup that you have - could you please open new support thread / forum post and provide the current Grid code, editor templates and model that you are using? This would help us pinpoint the exact reason for this behavior.
Regards,
Vladimir Iliev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
HI
I have the similar problem and I have tried the aspnetmvc\Examples\VS2015\Kendo.Mvc.Examples\Views\grid\editing_popup.cshtml.
Grid Popup Edit :
[UIHint("CategoryID2")]
public string CategoryID2 { get; set; }
In my EditorTemplates, the DropDownList get the list by using Action :
@model object
@(Html.Kendo().DropDownListFor(m => m)
.DataValueField("Value")
.DataTextField("Text")
.ValuePrimitive(true)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCategories", "Grid") ;
});
})
)
In Update action, I got the CategoryID2 = "[object Object]" before ValuePrimitive(true),
and got the CategoryID2 = "0004" after ValuePrimitive(true) :
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ProductViewModel product)
{
MY QUESTIONS ARE :
.Why the DropDownList in Grid Popup Edit need the ValuePrimitive(true) ?
.Why the general DropDownList (standlone DropDownList) do not need the ValuePrimitive(true) ?
.Why the DropDownList.ValuePrimitive do not default to true (Control built-in) ?
I think the DropDownList.ValuePrimitive default to false is very very very UNREASONABLE in physical implementation.
*Telerik DevCraft/UI for ASP.NET MVC R2 2017 SP1.
Best regards
Chris
>Why the general DropDownList (standlone DropDownList) do not need the ValuePrimitive(true) ?
means BindTo(IEnumerable<SelectListItem>) method.
The valuePrimitive settings comes in effect when the DropDownList is bound to a model, it has no effect on a DropDownList that does not have a value binding applied.
When the DropDownList is bound to a field of a model, the valuePrimitive setting determines the binding behavior of the DropDownList. If set to true, the underlying Grid model field will be updated with the selected item value field. If set to false, the Grid model field will be updated with the entire selected data item (with all its properties).
You can see, in the following example, that even a regular DropDownList, when put in an MVVM binding scenario needs the valuePrimitive setting to configure its binding behavior:
http://dojo.telerik.com/@tsveti/ABoZOxuL
The value binding behavior of list widgets (DropDownList, ComboBox, etc.) is explained in this article:
View-Model Fields with Value Field of Primitive Value
This behavior has been the default for quite some time now and changing it would be a breaking change in a lot of customer projects.
Regards,
Tsvetina
Progress Telerik