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

Grid Filtered Data Source

Thread ID:

Created:

Updated:

Platform:

Replies:

143033 Mar 1,2019 07:06 AM UTC Mar 4,2019 11:52 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: DataGrid
Rikard Schouwstra
Asked On March 1, 2019 07:06 AM UTC

Hi

I am looking for a way to get the data of a grid after filtering has been applied, how can this be achieved?

Regards

Thavasianand Sankaranarayanan [Syncfusion]
Replied On March 4, 2019 11:52 AM UTC

Hi Rikard, 

Greetings from Syncfusion. 

Based on your query we suspect that you want to get the filtered record from. So, we suggest you to use the below code example.    

In the below code example we have get the filtered record by clicking the external button. 

[index.html] 

<ejs-button id="clickbutton" content="getFilteredData"></ejs-button> 
 
<ejs-grid id="Grid" dataSource="ViewBag.dataSource" allowPaging="true" allowFiltering="true"> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="100"></e-grid-column> 
        <e-grid-column field="CustomerID" headerText="Customer ID" width="100"></e-grid-column> 
        <e-grid-column field="EmployeeID" headerText="Employee ID" width="100"></e-grid-column> 
        <e-grid-column field="Freight" width="100"></e-grid-column> 
        <e-grid-column field="Verified" headerText="Verified" width="100"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 
 
 
<script> 
    document.getElementById('clickbutton').addEventListener('click', function (e) { 
        var f_data; 
        var grid = document.getElementById('Grid').ej2_instances[0]; 
        var query = grid.renderModule.data.generateQuery(); // get grid corresponding query  
        for (var i = 0; i < query.queries.length; i++) { 
            if (query.queries[i].fn == 'onPage') { 
                query.queries.splice(i, 1);       // remove page query to get all records  
                break; 
            } 
        } 
        var dm = new ej.data.DataManager(grid.dataSource) 
        f_data = dm.executeLocal(query); 
        alert(f_data.length); 
        }  
    ); 
</script> 



Please let us know if you need further assistance on this. 

Regards, 
Thavasianand 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