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

[Solved] ajax bound grid in tab strip with load on demand server error 500

2 Answers 114 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alden
Top achievements
Rank 1
Alden asked on 10 Dec 2011, 08:06 AM
Hi,

I have tried to follow the numerous examples of ajax bound grids in tab strips in this forum, but my grid is still not working.  Here is a very simplified version.
Model:
public class TaskViewData
   {
       [HiddenInput(DisplayValue = false)]
       public int Id { get; set; }
 
       [Required(AllowEmptyStrings = false, ErrorMessage = "Please enter a task name.")]
       [DisplayName("Task Name")]
       public string Name { get; set; }
 
   }
Controller:
public ActionResult Index()
{
    return View();
}
 
[GridAction]
public ActionResult _AjaxMyTasks()
{
    return View("_TaskGrid", new GridModel(db.Tasks.Where(t => t.PersonId == me.Id).Select(s => new TaskViewData {
        Id = s.Id,
        Name = s.Name
    })));
}
 
public ActionResult MyTasks()
{
    FillViewBag(); // fill the view bag with stuff we need for editing
    return PartialView("_TaskGrid");
}
Index View:
@{ Html.Telerik().TabStrip()
        .Name("TabStrip")
        .Items(parent => {
            parent.Add()
                .Text("My Tasks")
                .Selected(true)
                .LoadContentFrom("MyTasks", "Tasks");
            parent.Add()
                .Text("Team Tasks")
                .LoadContentFrom("TeamTasks", "Tasks");
        })
        .Render();
}
_TaskGrid:
@model IEnumerable<fwf.ViewModels.TaskViewData>
@using System.Collections
    <div>
    @(Html.Telerik().Grid(Model).Name("TaskGrid")
                .ToolBar(commands => commands.Insert())
                .DataKeys(keys => keys.Add(c => c.Id))
        .DataBinding(dataBinding => dataBinding
              .Ajax().Select("_AjaxMyTasks", "Tasks"))
        .Columns(c =>
        {
            c.Bound(o => o.Name).Width(210);
            c.Command(commands =>
            {
                commands.Edit();
                commands.Delete();
            }).Width(200);
        });
)
</div>
What I see is that MyTasks() gets called, but is unable to render the grid, and _AjaxMyTasks is never called.  I receive a server error 500.  I took the advice of this blog post: http://blogs.telerik.com/aspnetmvcteam/posts/10-01-25/resolving-circular-references-when-binding-the-mvc-grid.aspx and created a separate view model, but I still have the same issue.

What am I missing, here?

2 Answers, 1 is accepted

Sort by
0
Alden
Top achievements
Rank 1
answered on 10 Dec 2011, 07:06 PM
Solved.  Firebug revealed a syntax error here:
.Columns(c =>
{
    c.Bound(o => o.Name).Width(210);
    c.Command(commands =>
    {
        commands.Edit();
        commands.Delete();
    }).Width(200);
}); <---- that semicolon is a syntax error
Lesson -- always use firebug :-)
0
Anurag
Top achievements
Rank 1
answered on 04 Jul 2012, 02:52 PM
I m using the same logic, but it only shows the index view of first tab because its .selected field is true by default. and when i change the controller name of second tab than it works fine. or otherwise if i change the .selected field of second than first index is not working. please help me.
Tags
TabStrip
Asked by
Alden
Top achievements
Rank 1
Answers by
Alden
Top achievements
Rank 1
Anurag
Top achievements
Rank 1
Share this question
or