My 2 new edit fields to not get read or writen to the database. They do however save to the model in memory and persist in the view. All other fields save to the DB.
In my MVC Task scheduler I have created a 2 custom fields called (Completed and OnHold) both boolean. I have created a CustomEditorTemplate.cshtml and reference it in index.cshtml.
.Editable(editable =>
{
editable.TemplateName("CustomEditorTemplate");
})
I have added to the DB then refreshed EF 6 successfully. I have added both fields to all the same Controllers and Models. The same as the existing boolean field call "IsAllDay". The only place where my fields don't exist and "IsAllDay" does is the kendo.all.min.js file. The field "IsAllDay" is in kendo.all.min.js seven times. If it was not a minified file I could read it.
Is that my problem? The js file?
Thanks for looking :)
4 Answers, 1 is accepted
You can check this sample application where is used a Custom View with custom field. Hope this will help you solve the issue.
Regards,
Plamen
Progress Telerik
Thanks for the reply.
I am using Telerik UI for ASP.NET MVC so have tried these samples already and have looked at the kendo examples you pointed out.
I have added my 2 new fields to the db and EF and the models, edited my pages and have created my custom template. In debug mode visually all pages persist the 2 new fields. However after an Insert/Update/Delete nothing gets saved in the backend database.
When I search inside kendo.all.min.js this file has Insert/Update/Delete and references all sample fields. But of course my 2 new fields are not referenced in kendo.all.min.js. Too hard to edit a min file. Too bad your samples did not include the not min files.
Again... visually I am done. There is not on-line examples of adding new database fields that save to the database.
Changing kendo.all.min.js is next to impossible.
What do you suggest?
You can find download the non minified version of the scripts from you account and test against it. It will also be useful if you point how to replicate the unusual behavior with some existing project -maybe with dummy data so that we could inspect the actual issue and be more helpful
Regards,
Plamen
Progress Telerik
I finally have my 2 new bool fields saving to the database. The solution was quite simple and came to me when I wondered how OwnerID saved via the BindTo for OwnerID in index.cshtml
In index.cshtml I added a resource.Add() for each of my new custom bool fields with values of true and false to match my bool value.
See below. I hope that helps others. Maybe I'm blind but I spend days searching the forms and did not find this as a solution.
Cheers everybody!!!
.Editable(editable =>
{
editable.TemplateName("CustomEditorTemplate");
})
.Timezone("Etc/UTC")
.Resources(resource =>
{
resource.Add(m => m.OwnerID)
.Title("Department")
.DataTextField("Text")
.DataValueField("Value")
.DataColorField("Color")
.BindTo(new[] {
new { Text = "Electrical", Value = 1, Color = "#51a0ed" } ,
new { Text = "Parks", Value = 2, Color = "#33cc33" } ,
new { Text = "Utilities", Value = 3, Color = "#ffff00" } ,
new { Text = "Roads", Value = 4, Color = "#ff1a1a" },
new { Text = "Mechanics", Value = 5, Color = "#47d1d1" },
new { Text = "Carpenters", Value = 6, Color = "#c87d0e" },
new { Text = "STP", Value = 7, Color = "#cc80ff" },
new { Text = "Other", Value = 8, Color = "#a9a9a9" }
});
resource.Add(m => m.Completed)
.Title("Completed")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new[] {
new { Text = "Yes", Value = true } ,
new { Text = "No", Value = false }
});
resource.Add(m => m.OnHold)
.Title("OnHold")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(new[] {
new { Text = "Yes", Value = true } ,
new { Text = "No", Value = false }
});
})
.DataSource(d => d
.Model(m =>
{
m.Id(f => f.TaskID);
m.Field(f => f.Title).DefaultValue("No title");
m.Field(f => f.OwnerID).DefaultValue(1);
m.Field(f => f.Title).DefaultValue("No title");
m.RecurrenceId(f => f.RecurrenceID);
m.Field(f => f.Completed).DefaultValue(false);
m.Field(f => f.OnHold).DefaultValue(false);
})
.Read("Read", "Scheduler")
.Create("Create", "Scheduler")
.Destroy("Destroy", "Scheduler")
.Update("Update", "Scheduler")
.Filter(filters =>
{
filters.Add(model => model.OwnerID).IsEqualTo(1).Or().IsEqualTo(2).Or().IsEqualTo(3).Or().IsEqualTo(4).Or().IsEqualTo(5).Or().IsEqualTo(6).Or().IsEqualTo(7).Or().IsEqualTo(8);
})
)