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

[Solved] Error on updating AJAX grid

6 Answers 181 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Datamex
Top achievements
Rank 2
Datamex asked on 27 Mar 2011, 05:06 PM
Hello,

I've setup an Ajax enabled MVC grid. Inserting and deleting records work ok, updating doesn't. I use TryUpdateModel as suggested in the demo, but for some reason that returns:

"Value cannot be null.\r\nParameter name: entity"

The weird thing is that I also use TryUpdateModel on insert, and then it works fine. So I'm not sure what goes wrong on update or what I could do to find out. As a workaround, I'm now updating directly from the FormCollection parameter, but since that's hardcoded I'd rather use TryUpdateModel instead.

Here's the grid code:

<%= Html.Telerik().Grid<ApplicationCategory>()
          .Name("Grid")
          .DataKeys(keys => 
            {
              keys.Add(c => c.ApplicationCategoryId);
            })
          .ToolBar(commands => 
            {
              commands.Insert();
            })
          .DataBinding(dataBinding =>
            {
              dataBinding.Ajax()
                .Select("SelectApplicationCategories""Admin")
                .Insert("InsertApplicationCategory""Admin")
                .Update("UpdateApplicationCategory""Admin")
                .Delete("DeleteApplicationCategory""Admin");
            })
          .Columns(columns =>
            {
              columns.Bound(c => c.Name).Width(360);
              columns.Command(commands =>
              {
                commands.Edit();
                commands.Delete();
              }).Width(200);
            })
          .Editable(editing => editing.Mode(GridEditMode.InLine))
    %>


And the controller code:

    [Authorize(Roles = "Admin")]
    [GridAction]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult UpdateApplicationCategory(Guid id, FormCollection form)
    {
      ApplicationCategory category = adminRepository.GetApplicationCategory(id);

      TryUpdateModel(category);
      adminRepository.Save();

      //Rebind the grid            
      return View(new GridModel(adminRepository.GetApplicationCategories()));
    }

6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 28 Mar 2011, 07:34 AM
Hello Datamex,

 This could be related to a bug which we have recently fixed. Please try upgrading to the latest internal build.

Regards,
Atanas Korchev
the Telerik team
0
Datamex
Top achievements
Rank 2
answered on 28 Mar 2011, 07:41 AM
Hello Atanas,

I'll try that, thanks. If it doesn't solve the problem I'll get back to you here.

0
Datamex
Top achievements
Rank 2
answered on 28 Mar 2011, 07:51 PM

Hello Atanas,

I tried the internal build, but it I'm affraid it breaks more then it does good. On a working page, I now get the following error:

"Error: Object doesn't support property or method 'tGrid'"

Grid code:

<%  Html.Telerik().Grid(Model)
          .Name("Grid")
          .DataKeys(keys =>
            {
              keys.Add(c => c.ApplicationId);
            })
          .DataBinding(dataBinding =>
            {
              dataBinding.Server()
                .Select("SelectApplications""Admin")
                .Delete("DeleteApplication""Admin");
            })
          .Columns(columns =>
            {
              columns.Bound(c => c.Name).Width(360);
              columns.Command(commands =>
              {
                commands.Delete();
              }).Width(200);
            })
          .Render();
    %>
0
Atanas Korchev
Telerik team
answered on 29 Mar 2011, 07:39 AM
Hi Datamex,

 This means that the JavaScript files of the grid have not loaded. Sometimes this indicates an incomplete upgrade. You can check this help topic which highlights the upgrade procedure.

 If this does not help I would ask you to provide some sample code which we can test with. 


Regards,
Atanas Korchev
the Telerik team
0
Datamex
Top achievements
Rank 2
answered on 29 Mar 2011, 07:53 PM
You were absolutely right, I didn't upgrade ok.

One request, could the upgrade page (http://www.telerik.com/help/aspnet-mvc/getting-started-upgrading.html) be altered so the "automatic upgrade" section is listed first? I'd done all manual steps when I found out there's an automated procedure as well :)
0
Scott
Top achievements
Rank 1
answered on 17 May 2011, 04:24 AM
For those of us running the open source 2011.1.315 build, when will the latest internal build become available for download so we can have this problem fixed as well?

Thanks!
Tags
Grid
Asked by
Datamex
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Datamex
Top achievements
Rank 2
Scott
Top achievements
Rank 1
Share this question
or