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

[Solved] Ajax Binding Always Showing Empty Data

1 Answer 80 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.
Sean
Top achievements
Rank 1
Sean asked on 05 Sep 2011, 12:36 AM
I really hope this is pilot error on my part - I must be missing something very simple here...

namespace TelerikMvcApplication7.Controllers {
    public class EntryViewModel {
        public int ID { get; set; }
        public string FileName { get; set; }
        public int FK { get; set; }
    }

    public class HomeController : Controller {
        [GridAction]
        public ActionResult _SelectPicturesGrid() {
            var results = new List<EntryViewModel>();

            results.Add(new EntryViewModel { ID = 1, FK = 2, FileName = "test" });
            results.Add(new EntryViewModel { ID = 2, FK = 2, FileName = "test2" });

            return View(results);

        }
}



 @(Html.Telerik().Grid<TelerikMvcApplication7.Controllers.EntryViewModel>()
    .Name("Grid")
    .DataKeys(keys => {
        keys.Add(p => p.ID);
    })
    .DataBinding(dataBinding => {
        dataBinding.Ajax()
            .Select("_SelectPicturesGrid", "Home");
    })
    .Columns(columns => {
        columns.Bound(p => p.FileName).Width(210);
        columns.Bound(p => p.FK);
    })
    .Pageable().Scrollable().Sortable()
 )


I thought maybe I was missing a script registrar, but I'm using the Telerik MVC 3 template so I'm not sure what I'm missing???

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
@(Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.default.css").Combined(true).Compress(true)))</head>

<body>
    <div class="page">

        <div id="header">
            <div id="title">
                <h1>My MVC Application</h1>
            </div>
           
            @(Html.Telerik().Menu()
                    .Name("menu")
                    .Items(menu => {
                        menu.Add().Text("Home").Action("Index", "Home");
                        menu.Add().Text("About").Action("About", "Home");
                    }))
        </div>

        <div id="main">
            @RenderBody()
            <div id="footer">
            </div>
        </div>
    </div>
@(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)))</body>
</html>

1 Answer, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 1
answered on 05 Sep 2011, 12:50 AM
Grrrrr...Yeah it was pilot error. Forgot to wrap my list in a new GridModel
Tags
Grid
Asked by
Sean
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 1
Share this question
or