First off, I am very new to MVC, so apologies in advance.
I don't know what I'm missing, but I have an enum type:
public enum ClientStatus
{
[Description("Unknown")]
Unknown = 0,
[Description("Normal")]
Normal = 1,
[Description("Legal Hold")]
LegalHold = 200
}
There is a database field which holds the integer value corresponding to the enum type. For my grid, I have:
Html.Kendo().Grid<IST.DocstorClient.Database.cache_dsl_client>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(o => o.dsl_client_id).Title("Client ID").EditorTemplateName("#dsl_client_id#");
columns.Bound(o => o.dsl_client_name).Title("Client Name");
columns.Bound(o => o.dsl_client_description).Title("Description");
columns.Bound(o => o.dsl_client_status).Title("Status").ClientTemplate("#=status_name#").EditorTemplateName("ClientStatus");
columns.Command(cmd => cmd.Destroy());
})
.ToolBar(toolbar =>
{
toolbar.Create();
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Pageable()
.Navigatable()
.PersistSelection()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.PageSize(10)
.Model(model =>
{
model.Id(p => p.dsl_client_id);
model.Field(p => p.dsl_client_id).Editable(false);
})
.Events(events => events.Error("dsr_error_handler"))
.Read("Editing_Read", "Client")
.Create("Editing_Create", "Client")
.Update("Editing_Update", "Client")
.Destroy("Editing_Destroy", "Client")
The item in question here is the column for dsl_client_status, which is defined as a byte? type in the Entity Framework definitions.
I also have a dropdown definition in Shared/EditorTemplates:
@(Html.Kendo().DropDownListFor(m => m)
.Name("ClientStatus")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(EnumHelper.GetSelectList(typeof(IST.DocstorClient.Data.ClientStatus)))
.OptionLabel("Select Status")
.Value(((int)Model).ToString())
)
I have been through a lot of iterations of different things, this is just the state things are in at the moment.
When I click on the cell to edit, I do get the dropdown list, but it is defaulted to the "Select Status", as if there is no value assigned. I can then change the dropdown value, but the database value never gets updated. If I click on it again, the value I changed to shows on the dropdown.
For example:
initial value is "Unknown".
I click to edit, the dropdown list defaults to "Select Status".
I change to "Normal" and click Save Changes. Text still shows as "Unknown".
I click to edit again and the dropdown is defaulted to "Normal"
I've been scouring forums and blogs for days, trying all manner of suggestions, all to no avail. I find it hard to believe that this is that difficult a task to achieve, so I gotta think I'm missing something simple here.