This question is locked. New answers and comments are not allowed.
Hello,
I am creating a sample using Telerik MVC Grid bound to Dataset with AJAX paging/sorting enabled.
I downloaded the sample from following location and it works fine.
http://www.telerik.com/community/code-library/aspnet-mvc/grid/binding-to-datatable.aspx
When I try creating a sample on similar lines, initial information is populated in Grid but when next page is requested, new information doesn't get populated in Grid. On further investigation, found that ActionResult specified for AJAX call isn't invoked.
I tried comparing the two smaples but can't find any difference.
Wondering if someone can help correcting AJAX paging when bound with Dataset.
Model
Controller
_Layout.cshtml
View - Home/Index
Thanks.
I am creating a sample using Telerik MVC Grid bound to Dataset with AJAX paging/sorting enabled.
I downloaded the sample from following location and it works fine.
http://www.telerik.com/community/code-library/aspnet-mvc/grid/binding-to-datatable.aspx
When I try creating a sample on similar lines, initial information is populated in Grid but when next page is requested, new information doesn't get populated in Grid. On further investigation, found that ActionResult specified for AJAX call isn't invoked.
I tried comparing the two smaples but can't find any difference.
Wondering if someone can help correcting AJAX paging when bound with Dataset.
Model
namespace TelerikMvcApplication1.Models{ public class Detail { #region "Properties" public string companyName { get; set; } public string formName { get; set; } private DataTable getDataTableSchema { get { DataTable objDataTable = new DataTable(); objDataTable.Columns.Add(new DataColumn("Id", typeof(Guid))); objDataTable.Columns.Add(new DataColumn("Date of entry", typeof(DateTime))); objDataTable.Columns.Add(new DataColumn("IP Address", typeof(String))); objDataTable.Columns.Add(new DataColumn("Country Name", typeof(String))); return objDataTable; } } #endregion #region "Methods" public DataTable getUserFilledEnteries() { DataTable objDataTable = this.getDataTableSchema; for (int i = 0; i < 20; i++) { // Dummy data DataRow dr = objDataTable.NewRow(); dr[0] = Guid.NewGuid(); dr[1] = DateTime.Now; dr[2] = "192.168.1.1."; dr[3] = "Austria - " + i.ToString(); objDataTable.Rows.Add(dr); } return objDataTable; } #endregion }}Controller
namespace TelerikMvcApplication1.Controllers{ public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; TelerikMvcApplication1.Models.Detail objDetail = new TelerikMvcApplication1.Models.Detail(); return View(objDetail); } [GridAction] public ActionResult fetchUserEnteries() { TelerikMvcApplication1.Models.Detail objDetail = new TelerikMvcApplication1.Models.Detail(); return View(new GridModel(objDetail.getUserFilledEnteries())); } }}_Layout.cshtml
<!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.black.css").Combined(true).Compress(true)))</head><body> <div class="page"> <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"); })) </header> <section id="main"> @RenderBody() </section> <footer> </footer> </div>@(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)))</body></html>View - Home/Index
@model TelerikMvcApplication1.Models.Detail@using System.Data;@{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml";} @(Html.Telerik().Grid(Model.getUserFilledEnteries()) .Name("Grid") .Columns(columns => { foreach (DataColumn column in Model.getUserFilledEnteries().Columns) { columns.Bound(column.DataType, column.ColumnName); } }) .DataBinding(dataBinding => dataBinding.Ajax().Select("fetchUserEnteries", "Home")) .Pageable() .Sortable() .Filterable() .Groupable() )Thanks.