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

[Solved] Implementing inline editing

1 Answer 117 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
James
Top achievements
Rank 1
James asked on 07 Apr 2011, 03:13 AM
Greetings, all.  I just started using the MVC Extensions and I have to say, I'm very impressed (mostly because they're free!).  But I'm having a hard time getting inline editing working correctly, and I wonder if I'm missing something.  I have a very simple grid (two fields) where I would like the user to be able to edit one of the fields.  I've got the databinding working correctly, but the Edit button does not seem to be finding my controller method.  Here is the relevant code.

My grid declaration:
@Html.Telerik().Grid(Model.ProductCustomFields)
    .Name("ProductCustomFields")
    .DataKeys(dataKeys => dataKeys.Add(c => c.FieldId))
    .DataBinding(dataBinding => dataBinding
        .Ajax().Update("_UpdateProductCustomField", "Product", new { area = "Admin" })
        .Delete("_DeleteProductCustomField", "Product", new { area = "Admin" }))
    .Columns(columns =>
    {
        columns.Bound(o => o.FieldName).Title("Name").ReadOnly();
        columns.Bound(o => o.FieldValue).Title("Value");
        columns.Command(commands =>
        {
            commands.Edit();
            commands.Delete();
        });
    }).Footer(false)

My controller action method:
[HttpPost]
[GridAction]
public ActionResult _UpdateProductCustomField(int fieldId)
{
    var pcfs = Session["ProductCustomFields"] as List<ProductCustomFieldViewModel>;
    var pcf = pcfs.Where(c => c.FieldId == fieldId);
    TryUpdateModel(pcf);
    return View(new GridModel(pcfs));
}

However, whenever I click the "Edit" button, I do not hit my controller method.  Instead I get some odd URL that ends with: 1?ProductCustomFields-mode=edit

Am I missing something or doing something wrong?  I literally just started working with these controls no more than 2 hours ago, and I'm impressed with how much I've been able to implement in so little time.  But I'm following the help documentation to the letter, so I must be missing something.

Any help would be appreciated.  Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Dennis
Top achievements
Rank 1
answered on 11 Jul 2012, 07:13 PM
Here's what I think is happening. If you are already within that area you don't need to specify the area. Your method is looking for a parameter of int and you are not passing an integer in so your method in the grids eye is non existent.

here is what I think should work:
Ajax().Update("_UpdateProductCustomField", "Product", new { fieldId = 1 })

Let me know if that helps.
Tags
General Discussions
Asked by
James
Top achievements
Rank 1
Answers by
Dennis
Top achievements
Rank 1
Share this question
or