This question is locked. New answers and comments are not allowed.
Hi all,
After I did some testing, I could bind my JSON to grid from client side, but it does not display page information at lower part of my grid. When I click on header to sort, grid goes to server side and all content are gone.
I am just wandering is Telerik Grid control capable to support pure client side binding/paging/sorting?
My sample code of controller is:
My View is
My model is
After I did some testing, I could bind my JSON to grid from client side, but it does not display page information at lower part of my grid. When I click on header to sort, grid goes to server side and all content are gone.
I am just wandering is Telerik Grid control capable to support pure client side binding/paging/sorting?
My sample code of controller is:
public class HomeController : Controller { public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(string btnButton) { ResultViewModel data = new ResultViewModel(); data.EntityData = new List<MyEntity>(); for (int i = 0; i < 50; i++) { data.EntityData.Add(new MyEntity { Id = i, Name = "N" + i, Value1 = "V" + i }); } return Json(data); }
My View is
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% using (Ajax.BeginForm("Index", new AjaxOptions { HttpMethod = "Post", OnComplete = "SearchData.onComplete" })) { %> <input type="submit" id="btnButton" value="Click Me" /> <% } %> <%= Html.Telerik().Grid<MyEntity>().Name("SearchResult").Columns( columns => { columns.Bound(o => o.Id) .ClientTemplate("<input type='checkbox' name='checkedRecords' value='<#= Id #>' />") .Title("") .Width(40) .HtmlAttributes(new { style = "text-align:center" }); columns.Bound(o => o.Name); columns.Bound(o => o.Value1); }).Pageable().Sortable().Scrollable().Resizable(resizing => resizing.Columns(true)) %> <script type="text/javascript"> var SearchData = { onComplete: function (content) { var output = eval(content.get_response().get_object()); //alert(output); var grid = $('#SearchResult').data('tGrid'); grid.dataBind(output.EntityData); } } </script> </asp:Content>My model is
public class ResultViewModel { public List<MyEntity> EntityData { get; set; } } public class MyEntity { public int Id { get; set; } public string Name { get; set; } public string Value1 { get; set; } }