Paging and Grouping

Hello,


I'm using paging (only 100 records are loaded per page) and grouping, but grouping only groupes and shows count of items at the same page, even if they are spread through few pages. How can I make that grouping work properly with paging?

5 Replies

RS Renjith Singh Rajendran Syncfusion Team October 25, 2017 01:37 PM UTC

Hi Customer, 
 
Thanks for contacting Syncfusion support. 
 
We have analyzed your query and we suspect that you want to get the total count(items) from the dataSource to be displayed in group caption for individual groupings. Also we suspect that you are using some adaptor in grid with remote data. By default it will be display the count based on current page wise. In order to get the total count for individual groupings, we suggest you to use URL Adaptor and pass a total records to display in the caption while grouping.  

Refer the below code example 

[app.component.html] 
 
<ej-grid id="Grid" [dataSource]="gridData" allowGrouping="true" allowPaging="true" showSummary="true" [summaryRows]="summaryRows" showCaptionSummary="true"> 
    <e-columns> 
        <e-column field="OrderID" headerText="Order ID" width="80" [textAlign]="right"></e-column> 
        <e-column field="CustomerID" headerText="Customer ID" width="80" [textAlign]="right"></e-column> 
        <e-column field="OrderDate" headerText="OrderDate" width="80" [textAlign]="right"></e-column> 
        <e-column field="EmployeeID" headerText="Employee ID" width="80" [textAlign]="right"></e-column> 
        <e-column field="Freight" format="{0:C2}" width="80" [textAlign]="right"></e-column> 
    </e-columns> 
</ej-grid>     
 
[app.component.ts] 
 
export class AppComponent 
    { 
        public summaryRows=[{title: "Sum", summaryColumns: [{ summaryType: ej.Grid.SummaryType.Sum, displayColumn: "Freight", dataMember: "Freight" }]}]; 
        public gridData = ej.DataManager({ 
           url: " http://localhost:52410/Grid/DataSource", 
           adaptor: new ej.UrlAdaptor(),   //bind data for grid. 
}); 
 
GridController: 
 
public ActionResult DataSource(DataManager dm) 
        { 
            IEnumerable DataSource = new NorthwindDataContext().OrdersViews.ToList(); 
            DataOperations ds = new DataOperations(); 
            DataResult result = new DataResult(); 
            List<string> str = new List<string>(); 
            if (dm.Group != null) 
                result.groupDs = DataSource; //Pass wholeset of records – For grouping 
            if (dm.Sorted != null) 
                DataSource = ds.PerformSorting(DataSource, dm.Sorted); 
            DataSource = ds.PerformSkip(DataSource, dm.Skip); 
            result.result = DataSource.AsQueryable().Take(dm.Take); 
            result.count = DataSource.AsQueryable().Count(); 
            return Json(result, JsonRequestBehavior.AllowGet); 
        } 
        public class DataResult 
        { 
            public IEnumerable result { get; set; } 
            public int count { get; set; } 
            public IEnumerable aggregate { get; set; } 
            public IEnumerable groupDs { get; set; } 
        } 

Please find the screenshot below, 

 

 
If you still face the issue please get back to us with the following details. 

  1. Share the screenshot/ video of the issue that you have faced.
  2. Share the adaptor that you have used.
  3. Share the grid code that you have used to render.
  4. If possible please reproduce the issue in the simple sample
 
The provided information will help us to analyze the issue and provide you the response as early as possible. 

Please let us know if you need further assistance. 
 
 
Regards, 
Renjith Singh Rajendran. 



ME Me October 26, 2017 03:58 AM UTC

Hey,

Can you tell me what is groupDs? Simple array? But what if we have two or three columns grouped?
Moreover, do you return all records in groupDs for grouping, and later on only part of records (skip, take) for grid?




RS Renjith Singh Rajendran Syncfusion Team October 28, 2017 03:22 AM UTC

Hi Customer, 

We have analyzed your query. In order to get the total items count in the first page itself, you need to pass the entire records of the fields/columns you have grouped, so that the total items count can be calculated by comparing the total records. 

The groupDs is an array, when we pass records to groupDs it is possible to return the total items count in the first page itself. Please use the below code example to pass the grouped columns data alone to groupDs. 

result.groupDs = new NorthwindDataContext().OrdersViews.Select(s => new { s.CustomerID, s.OrderID }).ToList();//Here CustomerID and OrderID are the grouped columns 

Regards, 
Renjith Singh Rajendran. 



ME Me October 30, 2017 03:39 AM UTC

This is not solution for me as data which we pass would be millions of records - not efficient at all. There are no other ways? How about virtual scrolling? Maybe it works better and can only pass count for required groups instead of all records?



RS Renjith Singh Rajendran Syncfusion Team October 31, 2017 06:11 AM UTC

Hi Customer, 

In order to get the complete count of the grouped data at first page, it is a must to have the complete records at client side. This is why we have passed the complete data of the grouped fields to the client side. We are passing only the complete data of fields and not the entire datasource. If the data is not available at client side then getting the complete count of grouped data is not feasible. 

And also you have asked to achieve using virtual scrolling. There is no support for Grouping in Virtual scrolling. Moreover if we use virtual scrolling, without passing the complete records at client side getting the total count at first page is not feasible. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon