Razor webgrid ajax paging and sorting

I'm trying to learn how to use Razor WebGrid in MVC3. How does the ajaxUpdateCallback parameter work?

-------------Problems Reply------------

The ajaxUpdateCallback is the name of the javascript function that will get called after the server call is complete. The title of your question is regarding paging and sorting with the WebGrid which would look something like this...

@{
var grid = new WebGrid(canPage: true, rowsPerPage: ThisController.PageSize, canSort: true, ajaxUpdateContainerId: "grid");
grid.Bind(Model.Employees, rowCount: Model.TotalRecords, autoSortAndPage: false);
grid.Pager(WebGridPagerModes.All);
@grid.GetHtml(htmlAttributes: new { id="grid" },
columns: grid.Columns(
grid.Column(format: (item) => Html.ActionLink("Edit", "Edit", new { EmployeeID = item.EmployeeID })),
grid.Column("FullName"),
grid.Column("Title")
));
}

I have a full example here if you'd like to see it:

Example

The ajaxUpdateCallBack parameter is used to specify the JavaScript function that should be called when the element denoted by the ajaxUpdateContainerId value has been updated as a result of sorting or paging etc. You pass it into the constructor like this:

var grid = new WebGrid(data, ajaxUpdateContainerId : "grid",
ajaxUpdateCallback: "callBack");

And it will point to this:

function callBack(){
alert('Called Back');
}

Category:asp.net mvc 3 Views:11 Time:2010-12-03

Related post

  • webgrid ajax paging and sorting, asp.net mvc3 razor 2012-03-12

    I am using a Webgrid in my project to display data, and have it working fine with paging and sorting. I have included a hyperlink column for "Slmgreferencenumber" like this: grid.Column("SlmgReferenceNumber", header: "SLMG Number", format: @<text

  • Why aren't MVC3 webgrid paging and sorting working? 2011-11-04

    I'm using MVC3 webgrid to display, sort and paginate data. The display is fine, but when I click on a new page or request a sort, nothing is happening. This is the code that I'm using: @if (Model.AdsList != null) { WebGrid adGrid = new WebGrid(Model.

  • Ajax Paging/sorting in cakephp 2.0 2012-02-17

    I am using cakephp 2.0 and trying to create ajax paging which i cant in the documentation i read that passing this $this->Paginator->options( array('update'=>'#box', 'evalScripts' => true, 'before' => $this->Js->get('#loaderIDast

  • Asp.net Mvc3 webgrid and paging 2011-06-14

    I am trying to learn Asp.net mvc. I know its different from forms and i need to change my way of thinking probably. My problem is about webgrid . When i add webgrid to my page and hit search button with Post it renders table with pager and so on. But

  • MVC3 paging and sorting without grid? 2011-07-26

    I was wondering if it's possible to implement paging and sorting of data using a @foreach Razor syntax instead of using a specific Grid control. Would it be difficult to implement? Should I stick to existing Grid solutions instead, such as WebGrid or

  • ASP.NET MVC 3.0 WebGrid - Ajax Enabled 2011-12-21

    I'm encountering the following problem: "A JQuery script reference is required in order to enable Ajax support in the "WebGrid" helper" I want to make my WebGrid AJAX enabled. I got this code for the Partial View @ModelType WebGrid @Model.GetHtml(tab

  • Storing search result for paging and sorting 2010-02-15

    I've been implementing MS Search Server 2010 and so far its really good. Im doing the search queries via their web service, but due to the inconsistent results, im thinking about caching the result instead. The site is a small intranet (500 employees

  • jqGrid on Clientside – paging/editing/sorting queries 2010-07-07

    I'm trying to build a system using jqgrid which does everything on the clientside, i.e. use AJAX to retrieve a JSON object (using C#/.Net) and cache this in a javascript variable and then populate several grids from that cache (addRowData), depending

  • Telerik-grid paging and sorting when using an external data source 2011-12-15

    I am experimenting with using an external data source with a Telerik Grid using their Twitter search sample as my guide http://demos.telerik.com/aspnet-mvc/razor/grid/externalservicetwitter I have got their sample running but cannot get paging and so

  • Ajax Paging working in development but not in production (heroku) - Rails 3.1 2011-12-17

    Somehow ajax paging is working in my Rails 3.1 development environment but not when i deploy it to heroku. The paging id working but without ajax. I know that's a lot of code. But i prefer not to miss out files which might be important. Could it have

  • Telerik Grid paging and Sorting in ASP.Net MVC3(aspx engine) 2012-02-12

    I am using Telerik Rad Grid in MVC3(aspx engine) like:- This is my Controller:- [HttpGet] [GridAction(EnableCustomBinding = true)] public ActionResult Search() { SearchViewModel searchViewModel = new SearchViewModel(this.serviceInvoker); SearchReques

  • Click event does not work after ajax paging 2009-03-27

    I really hope someone can help with this problem. I have an ajax pagination script that works great on the first page but the click events will not work on any other pages from the paging. This is how I have it setup: jQuery script <script type="t

  • paging and sorting using jquery 2009-09-01

    I want to use paging and sorting using jquery.I want to embed this with jsp/servlets at back end. --------------Solutions------------- Ingrid, the jQuery Datagrid. is a nice jQuery grid with paging and sorting options. Some more options Flexigrid jQG

  • Are there any good examples of ajax paging? 2009-09-11

    i have a page that displays large datasets into html tables. how can i add paging without having to refresh the whole page each time i change pages --------------Solutions------------- Basically you just need a page for your form submission, and give

  • GridView sorting doesn't work when I Enable Caching in Custome Paging and sorting 2009-12-29

    I have a GridView that use a stored procedure for custom paging and sorting . It's OK and works fine (Both paging and sorting) , But the problem is when i Enable Caching in ObjectDataSource like : EnableCaching="True" It properly cache every page tha

  • Gridview paging and sorting do not work after changing datasource in codebehind? 2010-03-05

    I am having a gridview with an object datasource binded in the markup(aspx page). When page loads it directly works fine with all sorting and paging properties. However, i need to filter display on gridview so i have to change the datasource of the g

  • LinqToSQL + paging + dynamic sort? 2010-03-11

    I have a problem on using LinqToSQL with paging + dynamic sorting. These are my sample code. Using db As New MyDataContext(connectionString) db.Log = new DebuggerWritter Dim result = db.User.OrderBy(Function(u) u.UserId) result = result.Skip((pageNo

  • MVC Paging and Sorting Patterns: How to Page or Sort Re-Using Form Criteria 2010-04-26

    What is the best ASP.NET MVC pattern for paging data when the data is filtered by form criteria? This question is similar to: http://stackoverflow.com/questions/1425000/preserve-data-in-net-mvc but surely there is a better answer? Currently, when I c

  • GridView ObjectDataSource LINQ Paging and Sorting using multiple table query 2010-06-16

    I am trying to create a pageing and sorting object data source that before execution returns all results, then sorts on these results before filtering and then using the take and skip methods with the aim of retrieving just a subset of results from t

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.224 (s). 11 q(s)