|
Index.cshtml
<ejs-grid id="Grid" height="273" allowPaging="true" allowFiltering="true">
<e-data-manager url="/Home/UrlDataSource" adaptor="UrlAdaptor"></e-data-manager>
<e-grid-filterSettings type="Excel"></e-grid-filterSettings>
<e-grid-columns>
<e-grid-column field="CustomerID" headerText="Customer ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column>
<e-grid-column field="ContactName" headerText="Contact Name" type="string" width="120"></e-grid-column>
<e-grid-column field="ContactTitle" headerText="ContactTitle" textAlign="Right" width="120"></e-grid-column>
<e-grid-column field="City" headerText="Ship City" width="150"></e-grid-column>
</e-grid-columns>
</ejs-grid> |
|
[Homecontroller.cs]
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
EFDataContext db = new EFDataContext();
IQueryable<Customers> DataSource = db.customers;
QueryableOperation operation = new QueryableOperation();
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);
}
int count = DataSource.Count();
if (dm.Skip != 0)
{
DataSource = operation.PerformSkip(DataSource, dm.Skip); //Paging
}
if (dm.Take != 0)
{
DataSource = operation.PerformTake(DataSource, dm.Take);
}
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
} |
Hi friends,I looked up on this forum but I didn't find an answer.I have a Grid using Handling On-Demand grid actions for load large amount of data.For example, with your sample each call of grid paging, call to UrlDataSource method and load the entire amount of data, it's slow:IEnumerable DataSource = OrdersDetails.GetAllRecords();I have replaced it with:IReadOnlyList<Customer> DataSource = _customerService.ListAllPaginatedAsync(dm.skip, dm.take);This loads large amount of data verywell.My issue is about filter. It only load the first 1000 values when i'm trying to use it. This is the http head request:{take: 1000}take: 1000Is there another way to load whole filter values?
|
// Grid’s actionBegin event function
function onActionBegin(args) {
if (args.requestType === "filterchoicerequest") {
// Filter choice count is modified
args.filterChoiceCount = 1500;
}
} |
|
function onActionBegin(args) {
if (args.requestType === "filterbeforeopen") {
customDataSource = DataUtil.distinct(categoryData, ‘Discontinued’, true); // categoryData – grid data, Discontinued – required field
}
} |
|
<script>
function begin(args) {
if (args.requestType === "filterchoicerequest") {
var filterfields = [];
var objFilter = Object.keys(args.filterModel.existingPredicate);
for (var i = 0; i < objFilter.length; i++) {
filterfields.push(objFilter[i]);
}
filterfields.push(args.filterModel.options.field);
args.query.distincts = [];
args.query.select(filterfields); // Created the select query
}
}
</script>
|
|
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm)
{
IEnumerable DataSource = order;
DataOperations operation = new DataOperations();
. . . . . . . .
int count = DataSource.Cast<Orders>().Count();
if (dm.Select != null)
{
DataSource = operation.PerformSelect(DataSource, dm.Select); // Selected the columns value based on the filter request
DataSource = DataSource.Cast<dynamic>().Distinct().AsEnumerable(); // Get the distinct values from the selected column
}
. . . . . .
return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);
}
|