@(Html.DevExtreme().DataGrid()
.ID("gridContainer")
.ShowBorders(true)
.Scrolling(scrolling => scrolling.RowRenderingMode(GridRowRenderingMode.Virtual))
.Paging(paging => paging.PageSize(10))
.Pager(pager => {
pager.Visible(true);
pager.DisplayMode(GridPagerDisplayMode.Full);
pager.ShowPageSizeSelector(true);
pager.AllowedPageSizes(new JS("[5, 10, 'all']"));
pager.ShowInfo(true);
pager.ShowNavigationButtons(true);
})
.CustomizeColumns(@<text>
function(columns) {
columns[0].width = 70;
columns[4].dataType = "date";
}
</text>)
.DataSource(d => d.Mvc().Controller("DataGridScrolling").LoadAction("Get").Key("Id"))
)
<div class="options">
<div class="caption">Options</div>
<div class="option-container">
<div class="option">
@(Html.DevExtreme().SelectBox()
.ID("displayMode")
.DataSource(new[] { new { text= "Display Mode 'full'", value= "full" }, new { text= "Display Mode 'compact'", value= "compact" } })
.DisplayExpr("text")
.InputAttr("aria-label", "Display Mode")
.ValueExpr("value")
.Value("full")
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
var showInfo = $("#showInfo").dxCheckBox("instance");
var navButtons = $("#showNavButtons").dxCheckBox("instance");
dataGrid.option("pager.displayMode", data.value);
showInfo.option("disabled", data.value === "compact");
navButtons.option("disabled", data.value === "compact");
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("showPageSizes")
.Text("Show Page Size Selector")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("pager.showPageSizeSelector", data.value);
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("showInfo")
.Text("Show Info Text")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("pager.showInfo", data.value);
}
</text>)
)
</div>
<div class="option">
@(Html.DevExtreme().CheckBox()
.ID("showNavButtons")
.Text("Show Navigation Buttons")
.Value(true)
.OnValueChanged(@<text>
function(data) {
var dataGrid = $("#gridContainer").dxDataGrid("instance");
dataGrid.option("pager.showNavigationButtons", data.value);
}
</text>)
)
</div>
</div>
</div>
using DevExtreme.NETCore.Demos.Models;
using DevExtreme.NETCore.Demos.Models.DataGrid;
using DevExtreme.NETCore.Demos.Models.SampleData;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace DevExtreme.NETCore.Demos.Controllers {
public class DataGridController : Controller {
public ActionResult RecordPaging() {
return View();
}
}
}
using DevExtreme.AspNet.Data;
using DevExtreme.AspNet.Mvc;
using DevExtreme.NETCore.Demos.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
namespace DevExtreme.NETCore.Demos.Controllers.ApiControllers {
[Route("api/[controller]")]
public class DataGridScrollingController : Controller {
[HttpGet]
public object Get(DataSourceLoadOptions loadOptions) {
return DataSourceLoader.Load(GenerateData(100000), loadOptions);
}
IEnumerable<User> GenerateData(int count) {
var surnames = new[] { "Smith", "Johnson", "Brown", "Taylor", "Anderson", "Harris", "Clark", "Allen", "Scott", "Carter" };
var names = new[] { "James", "John", "Robert", "Christopher", "George", "Mary", "Nancy", "Sandra", "Michelle", "Betty" };
var gender = new[] { "Male", "Female" };
var startBirthDate = DateTime.Parse("1/1/1975");
var endBirthDate = DateTime.Parse("1/1/1992");
double s = 123456789;
double NextRandom() {
s = (1103515245 * s + 12345) % 2147483647;
return s % (names.Length - 1);
}
for(var i = 0; i < count; i++) {
var birthDate = new DateTime(startBirthDate.Ticks + Convert.ToInt64(Math.Floor(NextRandom() * (endBirthDate.Ticks - startBirthDate.Ticks) / 10)));
birthDate.AddHours(12);
var nameIndex = Convert.ToInt32(NextRandom());
yield return new User {
Id = i + 1,
FirstName = names[nameIndex],
LastName = surnames[Convert.ToInt32(NextRandom())],
Gender = gender[Convert.ToInt32(Math.Floor(Convert.ToDouble(nameIndex / 5)))],
BirthDate = birthDate
};
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
namespace DevExtreme.NETCore.Demos.Models {
public class User {
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Gender { get; set; }
public DateTime BirthDate { get; set; }
}
}
#gridContainer {
max-height: 800px;
}
.options {
margin-top: 20px;
padding: 20px;
background-color: rgba(191, 191, 191, 0.15);
position: relative;
}
.caption {
font-size: 18px;
font-weight: 500;
}
.option-container {
display: flex;
margin: 0 auto;
justify-content: space-between;
}
.option {
margin-top: 10px;
display: flex;
align-items: center;
}
.option-caption {
white-space: nowrap;
margin: 0 8px;
}