🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

Grid.Mvc.Ajax

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Grid.Mvc.Ajax

Extends the Grid.Mvc helper with AJAX paging, sorting, and column and form filtering.

1.0.31
NuGet
Version published
Maintainers
2
Created
Source

Follow thse steps to use Grid.Mvc.Ajax

  • Include ~/Scripts/gridmvc-ext.js after your ~/Scripts/grimvc.js include.

  • Include ~/Content/ladda-bootstrap/ladda-themeless.min.css CSS after your Bootstrap CSS/LESS include.

  • Include Ladda-bootstrap Javascript via the ~/Scripts/ladda-bootstrap/ladda.min.js and ~/Scripts/ladda-bootstrap/spin.min.js.

  • Create a view model for you grid data, for example: public Person { public string FirstName { get; set; } public string LastName { get; set; } }

  • Add a Razor partial view for your grid data that uses an AjaxGrid as the model type, Where T is your view model type:

@using GridMvc.Html @using GridMvc.Sorting @model Grid.Mvc.Ajax.GridExtensions.AjaxGrid<Models.Person>

@Html.Grid(Model).Columns(columns => { columns.Add(c => c.FirstName); columns.Add(c => c.LastName); }).Sortable(true).WithPaging(10)

  • Add a controller action to retrieve the data for the first page of data that includes the Ajax pager HTML:

public JsonResult Persons() { var vm = new List() { new Person() { FirstName = "John", LastName = "Doe" } } .AsQueryable(); var ajaxGridFactory = new Grid.Mvc.Ajax.GridExtensions.AjaxGridFactory(); var grid = ajaxGridFactory.CreateAjaxGrid(vm, 1, false); }

  • Add a controller action to retrieve data for paged items that returns a JsonResult without the Ajax page HTML:

public JsonResult PersonsPaged(int page) { var vm = new List() { new Person() { FirstName = "John", LastName = "Doe" } } .AsQueryable(); var ajaxGridFactory = new Grid.Mvc.Ajax.GridExtensions.AjaxGridFactory(); var grid = ajaxGridFactory.CreateAjaxGrid(vm, page, true); }

  • Call the ajaxify Grid.Mvc.Ajax JavaScript plug-in method setting the non-paged and paged controller actions and optionally a form to apply additional filtering to the grid. All input and select elements in the given form will be passed into your paged and non-paged controller actions:

$(".grid-mvc").gridmvc().ajaxify({ getPagedData: '/Home/Persons', getData : '/Home/PersonsPaged', gridFilterForm: $("#gridFilters") });

FAQs

Package last updated on 26 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts