"No parameterless constructor defined for this object" when updating grid

2 posts, 0 answers
  1. pmourfield
    pmourfield avatar
    32 posts
    Member since:
    Aug 2011

    Posted 30 Apr 2014 Link to this post

    Good afternoon. My Kendo Grid allows me to create new records, but when I try to update a record I get the following error:

    "No parameterless constructor defined for this object"

    I should note that if I do not change anything when the update popup appears and just click the update button, it works fine. Only if I change something and then click update do I get the error.

    Here is my grid code:

                .Columns(columns =>
                    columns.Bound(p => p.ExpenseReportId).Visible(true);
                    columns.Bound(p => p.ExpenseLineItemId).Visible(true);
                    columns.Bound(p => p.ExpenseTypeDesc).Title("Expense Type");
                    columns.Bound(p => p.City).Title("City");
                    columns.Bound(p => p.StateName).Title("State");
                    columns.Bound(p => p.Date).Format("{0:d}").Title("Date");
                    columns.Bound(p => p.Amount).Title("Amount");
                    columns.Bound(p => p.EndingMileage).Title("Ending Mileage");
                    columns.Bound(p => p.BeginningMileage).Title("Beginning Mileage");
                    columns.Command(command => { command.Edit(); command.Destroy(); });
                .ToolBar(toolbar => toolbar.Create().HtmlAttributes(new { id = "btnAdd" }))
                .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("NewExpense").Window(w => w.Width(500)))
                .HtmlAttributes(new { style = "height:430px; width=100%" })           
                .DataSource(dataSource => dataSource
                    .Events(events => events.Error("error_handler"))
                    .Model(model =>
                        model.Id(p => p.ExpenseReportId);
                        model.Id(p => p.ExpenseLineItemId);
                    .Create(create => create
                        .Action("EditingPopup_Create", "ExpenseReport")
                    //.Read(read => read
                    //    .Action("EditingPopup_Read", "ExpenseReport")
                    //    .Data("erLineItemsReadData"))
                    .Update(update => update
                        .Action("EditingPopup_Update", "ExpenseReport").Type(HttpVerbs.Post)
                    .Destroy(update => update
                        .Action("EditingPopup_Destroy", "ExpenseReport").Type(HttpVerbs.Post)))          
            function error_handler(e) {
                if (e.errors) {
                    var message = "Errors:\n";
                    $.each(e.errors, function (key, value) {
                        if ('errors' in value) {
                            $.each(value.errors, function () {
                                message += this + "\n";
            //pass additional data to the READ action method
            function erLineItemsReadData() {
                return {
                    expenseReportId: "@ViewBag.ExpenseReportId"
            function erLineItemsCreateData() {
                return {
                    expenseReportId: "@ViewBag.ExpenseReportId"
            function erLineItemsUpdateData() {
                return {
                    expenseReportId: "@ViewBag.ExpenseReportId",
                    expenseLineItemId: "@ViewBag.ExpenseLineItemId"

    Here is the controller code:

            public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, ExpenseReportModel erLineItem, int expenseReportId, int expenseLineItemId)
                if (erLineItem != null && ModelState.IsValid)
                    globalKip.UpdateExpenseReportLineItem(expenseReportId, erLineItem.ExpenseTypeDesc, erLineItem.Date, erLineItem.Amount, erLineItem.City, erLineItem.StateName, erLineItem.EndingMileage, erLineItem.BeginningMileage);
                return Json(new[] { erLineItem }.ToDataSourceResult(request, ModelState));

    Does anyone know what's going on here? 
  2. Vladimir Iliev
    Vladimir Iliev avatar
    2206 posts

    Posted 01 May 2014 Link to this post


    I already answered to this query in duplicated support ticket created by you - #815173. Please keep in mind that it is highly recommended that you keep related questions in one support thread or a forum post, so that we can easily keep track of your support history and provide better answers in a shorter time.

    For convenience I also included the response to the current thread:

    Basically the described behavior is caused by invalid models IDs - from the provided information it seems that you are trying to set two different fields for primary key which currently is not supported. In current case I can only suggest to create new ViewModel which to combine this two keys in single property.

    Vladimir Iliev

    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.

Back to Top