Extract data from Grid and populate Scatter Chart control and calculate information from the data


We are using your sync fusion grid

 

  1. The web page allows user to enter search data into a text box, user clicks a button and the grid gets populated from the database query – returns 100 rows.
  2. The user then filters the grid data by using the ‘excel’ like column header filters and reduces the grid lines shown down to 20
  3. We now want to get the data that is currently displayed in the grid (20 rows) into a popup window and run calculations on it and populate your Scatter Chart with the 20 rows of data

 

How can this be done since the data in the grid is being filtered by javascript/client side ?


2 Replies

PS Pavithra Subramaniyam Syncfusion Team May 22, 2018 01:10 PM UTC

Hi Buster, 

We have checked your query and you can achieve your requirement by using grid.currentViewData in the actionComplete event of Grid component with requstType ‘filtering’. We have prepared a simple sample based on your requirement in which you can get the currently displayed records in the actionComplete event after filter action has completed. Please refer to the below code example , Documentation link and sample link. 

[index.chtml] 
<div> 
   @Html.EJS().Grid("Grid").DataSource(dataManager => { dataManager.Url("/Home/UrlDatasource").Adaptor("UrlAdaptor"); }).Columns(col => 
{ 
.  .  . 
 
}).AllowPaging().AllowReordering().ActionComplete("complete").AllowFiltering(true).FilterSettings(filter => filter.Type(Syncfusion.EJ2.Grids.FilterType.Excel)).AllowResizing(true).ShowColumnChooser(true).Toolbar(new List<string>() { "Search", "ColumnChooser" }).PageSettings(page => page.PageSize(10)).Render() 
 
</div> 
<script> 
   function complete(e) { 
        if (e.requestType == 'filtering') { 
            var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0] 
            console.log(grid.currentViewData);   // you can make your calculations on this current view data 
        }  
    } 
    </script> 


Sample               : 

Regards, 
Pavithra S. 



PS Pavithra Subramaniyam Syncfusion Team May 22, 2018 01:24 PM UTC

Hi Buster, 

Sorry for the inconvenience. 

Please refer to the below sample link for your requirement. 


Regards, 
Pavithra S. 


Loader.
Up arrow icon