GIJGO
Examples
Documentation
Report a Bug
Download
Ajax Sourced Data
Local Data Source
HTML Sourced Data
Bootstrap 3
Bootstrap 4
Material Design
Angular 6
Formatting Sample
Template
Iniline Editing
Nested Grids
Connected Grids
Grid Localization
Grouping
Responsive Design 1
Responsive Design 2
Gijgo.com
Grid
Examples
Grid Localization
jQuery Grid Localization
This example shows how to configure different languages for your datagrid
Preview
Front-End Code
Back-End Code
Edit
Download ASP.NET Examples
<!DOCTYPE html> <html> <head> <title>jQuery Grid Localization</title> <meta charset="utf-8" /> <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/gijgo.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.fr-fr.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.bg-bg.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.de-de.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.pt-br.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.ru-ru.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.es-es.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.it-it.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.tr-tr.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.ja-jp.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.zh-cn.min.js" type="text/javascript"></script> <script src="https://unpkg.com/gijgo@1.9.14/js/messages/messages.zh-tw.min.js" type="text/javascript"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="https://unpkg.com/gijgo@1.9.14/css/gijgo.min.css" rel="stylesheet" type="text/css" /> <link href="/Content/demo.css" rel="stylesheet" type="text/css" /> </head> <body> <div class="gj-margin-top-10"> <form class="display-inline"> <label for="ddlLanguage">Language:</label> <select id="ddlLanguage"> <option value="en-us">English</option> <option value="fr-fr">French</option> <option value="bg-bg">Bulgarian</option> <option value="de-de" selected="selected">German</option> <option value="pt-br">Portuguese (Brazil)</option> <option value="ru-ru">Russian</option> <option value="es-es">Spanish</option> <option value="it-it">Italian</option> <option value="tr-tr">Turkish</option> <option value="ja-jp">Japanise</option> <option value="zh-cn">Chinise Simplified</option> <option value="zh-tw">Chinise Traditional</option> </select> </form> </div> <div class="gj-clear-both"></div> <div class="gj-margin-top-10"> <table id="grid"></table> </div> <script type="text/javascript"> var grid, gridConfig, dialog, dialogConfig; gridConfig = { locale: 'de-de', dataSource: '/Players/Get', uiLibrary: 'bootstrap', columns: [ { field: 'ID', width: 32 }, { field: 'Name', sortable: true, editor: true }, { field: 'PlaceOfBirth', title: 'Place Of Birth', sortable: true, editor: true } ], pager: { limit: 5 }, inlineEditing: { mode: 'command', managementColumnConfig: { width: 240 } } }; $(document).ready(function () { grid = $('#grid').grid(gridConfig); $('#ddlLanguage').on('change', function () { var newLang = $(this).val(); gridConfig.locale = newLang; grid.destroy(true, true); grid = $('#grid').grid(gridConfig); }); }); </script> </body> </html>
using Gijgo.Asp.NET.Examples.Models.Entities; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace Gijgo.Asp.NET.Examples.Controllers { public class PlayersController : Controller { public JsonResult Get(int? page, int? limit, string sortBy, string direction, string name, string nationality, string placeOfBirth) { List<Models.DTO.Player> records; int total; using (ApplicationDbContext context = new ApplicationDbContext()) { var query = context.Players.Select(p => new Models.DTO.Player { ID = p.ID, Name = p.Name, PlaceOfBirth = p.PlaceOfBirth, DateOfBirth = p.DateOfBirth, CountryID = p.CountryID, CountryName = p.Country != null ? p.Country.Name : "", IsActive = p.IsActive, OrderNumber = p.OrderNumber }); if (!string.IsNullOrWhiteSpace(name)) { query = query.Where(q => q.Name.Contains(name)); } if (!string.IsNullOrWhiteSpace(nationality)) { query = query.Where(q => q.CountryName != null && q.CountryName.Contains(nationality)); } if (!string.IsNullOrWhiteSpace(placeOfBirth)) { query = query.Where(q => q.PlaceOfBirth != null && q.PlaceOfBirth.Contains(placeOfBirth)); } if (!string.IsNullOrEmpty(sortBy) && !string.IsNullOrEmpty(direction)) { if (direction.Trim().ToLower() == "asc") { switch (sortBy.Trim().ToLower()) { case "name": query = query.OrderBy(q => q.Name); break; case "countryname": query = query.OrderBy(q => q.CountryName); break; case "placeOfBirth": query = query.OrderBy(q => q.PlaceOfBirth); break; case "dateofbirth": query = query.OrderBy(q => q.DateOfBirth); break; } } else { switch (sortBy.Trim().ToLower()) { case "name": query = query.OrderByDescending(q => q.Name); break; case "countryname": query = query.OrderByDescending(q => q.CountryName); break; case "placeOfBirth": query = query.OrderByDescending(q => q.PlaceOfBirth); break; case "dateofbirth": query = query.OrderByDescending(q => q.DateOfBirth); break; } } } else { query = query.OrderBy(q => q.OrderNumber); } total = query.Count(); if (page.HasValue && limit.HasValue) { int start = (page.Value - 1) * limit.Value; records = query.Skip(start).Take(limit.Value).ToList(); } else { records = query.ToList(); } } return this.Json(new { records, total }, JsonRequestBehavior.AllowGet); } [HttpPost] public JsonResult Save(Models.DTO.Player record) { Player entity; using (ApplicationDbContext context = new ApplicationDbContext()) { if (record.ID > 0) { entity = context.Players.First(p => p.ID == record.ID); entity.Name = record.Name; entity.PlaceOfBirth = record.PlaceOfBirth; entity.DateOfBirth = record.DateOfBirth; entity.CountryID = record.CountryID; entity.Country = context.Locations.FirstOrDefault(l => l.ID == record.CountryID); entity.IsActive = record.IsActive; } else { context.Players.Add(new Player { Name = record.Name, PlaceOfBirth = record.PlaceOfBirth, DateOfBirth = record.DateOfBirth, CountryID = record.CountryID, Country = context.Locations.FirstOrDefault(l => l.ID == record.CountryID), IsActive = record.IsActive }); } context.SaveChanges(); } return Json(new { result = true }); } [HttpPost] public JsonResult Delete(int id) { using (ApplicationDbContext context = new ApplicationDbContext()) { Player entity = context.Players.First(p => p.ID == id); context.Players.Remove(entity); context.SaveChanges(); } return Json(new { result = true }); } public JsonResult GetTeams(int playerId, int? page, int? limit) { List<Models.DTO.PlayerTeam> records; int total; using (ApplicationDbContext context = new ApplicationDbContext()) { var query = context.PlayerTeams.Where(pt => pt.PlayerID == playerId).Select(pt => new Models.DTO.PlayerTeam { ID = pt.ID, PlayerID = pt.PlayerID, FromYear = pt.FromYear, ToYear = pt.ToYear, Team = pt.Team, Apps = pt.Apps, Goals = pt.Goals }); total = query.Count(); if (page.HasValue && limit.HasValue) { int start = (page.Value - 1) * limit.Value; records = query.OrderBy(pt => pt.FromYear).Skip(start).Take(limit.Value).ToList(); } else { records = query.ToList(); } } return this.Json(new { records, total }, JsonRequestBehavior.AllowGet); } } }