We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to retrieve records after filtering / grouping without paging?

Thread ID:

Created:

Updated:

Platform:

Replies:

148366 Oct 16,2019 07:08 PM UTC Oct 18,2019 06:50 AM UTC ASP.NET MVC - EJ 2 3
loading
Tags: Grid
Juan Cruz
Asked On October 16, 2019 07:08 PM UTC

Hello, I am setting up a grid with ExportExcel, filtering, grouping, paging and I would like to be able to retrieve the records that are the result after filtering and grouping but without being limited by the paging (that only one page comes out and not all pages).
Something similar to when you filter and / or group and export to excel

My code in view:
@(Html.EJS().Grid("Facturas")
        .DataSource(ds=>ds.Url(Url.Action("DS")).Adaptor("UrlAdaptor").CrossDomain(true))
        .AllowExcelExport()
        .ShowColumnMenu()
        .AllowPaging()
        .AllowFiltering()
        .AllowGrouping()
        .FilterSettings(f => f.Type(Syncfusion.EJ2.Grids.FilterType.Excel))
        .Columns(c =>
        {
            c.Field("EquipoId").AllowEditing(false).IsPrimaryKey(true).Add();
            c.Field("PrecioBase").Format("C2").Add();
            c.Field("IVA").AllowEditing(false).Format("C2").Add();
            c.Field("TotalCliente").AllowEditing(false).Format("C2").Add();
            c.Field("Total").AllowEditing(false).Format("C2").Add();
        })
        .PageSettings(p=>p.PageSize(5))
        .EditSettings(es =>
        {
            es.AllowEditing(true);
        })
        .Toolbar(new string[] { "Edit", "Update", "Cancel", "ExcelExport" }).ToolbarClick("tclic")
        .ActionComplete("Completo")
        .Render()
)

<script>
    function tclic(args) {
        console.log(args);
        if (args.item.id === 'Facturas_excelexport') {

            var excelExportProperties = {
                fileName: "RepEquipos_" + "@DateTime.Now" + ".xlsx"
            };
            var grid = document.getElementById("Facturas").ej2_instances[0];
            var data = grid.dataSource;
            console.log(data);
            grid.excelExport(excelExportProperties);
        }
        }
    function Completo(args) {
        console.log(args);
        if (args.requestType === "filtering") {
            console.log(args);
            window.ids = new Array();
            var rows = args.rows;
            for (var i = 0; i < rows.length; i++) {
                if (!("key" in rows[i].data)) {
                    window.ids.push(rows[i].data);
                }
            }
        }
        if (args.requestType==="grouping") {
            console.log(args);
            window.ids = new Array();
            var rows = args.rows;
            for (var i = 0; i < rows.length; i++) {
                if (!("key" in rows[i].data)) {
                    window.ids.push(rows[i].data);
                }
            }
        }
    }
    function d1() {
        var x = window.ids;
        console.log(x);
        }

    window.addEventListener('DOMContentLoaded', function () {
        window.ids = new Array();
        });
    function test(args) {
        console.log(args);
    }
</script>

Can I retrieve all records after filtering or grouping of all pages and not just the current one?

Attachment: FilterGroup_bc92b794.rar

Pavithra Subramaniyam [Syncfusion]
Replied On October 17, 2019 11:17 AM UTC

Hi Juan, 
 
Greetings from Syncfusion. 
 
Query: ”How to retrieve records after filtering / grouping without paging ”. 
 
You can achieve your requirement by using generateQuery and executeQuery methods of EJ2 DataManager. Please refer to the below code blocks and sample link for more information. 
 
    @Html.EJS().Grid("Grid").DataSource(ds => ds.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor").InsertUrl("/Home/Insert").RemoveUrl("/Home/Remove") 
.UpdateUrl("/Home/Update")).Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").Width("120").IsPrimaryKey(true).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
. . . . 
}).Height("400").AllowExcelExport().AllowPaging().AllowFiltering(true).AllowGrouping().AllowSorting().FilterSettings(filter => { filter.Type(Syncfusion.EJ2.Grids.FilterType.Menu); }).ToolbarClick("toolbarClick").Toolbar(new List<string> 
        () { "ExcelExport" }).Render() 
</div> 
 
<script> 
     function toolbarClick(args) { 
        var gridObj = document.getElementById("Grid").ej2_instances[0]; 
         if (args.item.id === 'Grid_excelexport') { 
 
             var query = gridObj.renderModule.data.generateQuery(true); 
        // execute the action queries in getDataModule. 
             gridObj.getDataModule().executeQuery(query).then((e) => { 
                 console.log(e.result); // you can retrieve the all data after filter and grouping 
 
             }) 
            gridObj.excelExport(); 
        } 
     } 
</script> 
 
 
Screenshot : (After filtered with BLONP) 
 
 
 
 
Please get back to us if you need further assistance. 

Regards,
 
Pavithra S. 


Juan Cruz
Replied On October 17, 2019 02:30 PM UTC

I already did the test with the code you provided me and it works correctly. I only have one question: How can I handle if an error occurs in:
gridObj.getDataModule().executeQuery(query).then((e) => {
            console.log(e.result); // you can retrieve the all data after filter and grouping 

        })
I really appreciate your help

Pavithra Subramaniyam [Syncfusion]
Replied On October 18, 2019 06:50 AM UTC

Hi Juan, 
 
You can handle failure request by using the executeQuery catch method. Please find the below code example for more information. 
 
[index.cshtml] 
var query = gridObj.renderModule.data.generateQuery(true); 
                             // execute the action queries in getDataModule.. 
             new ej.data.DataManager({url:"gr"}).executeQuery(query).then((e) => { 
                 console.log(e.result); // you can retrive the all data after filter and grouping 
             }).catch((e) => { 
                 console.log(e.error); 
             }); 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon