What's the equivilant to ejGrid("getCurrentViewData") for ej2?

Before upgrading from ej1 to ej2, I was using this...

var rows = $("#myGrid").ejGrid("getCurrentViewData");

I just need access to the data that the current gridview page is bound to.

This is no longer working, saying that ejGrid isn't defined. What's the equivalent way to do this in ej2?

4 Replies

DC Dan Clarke May 1, 2020 12:54 PM UTC

I've just noticed on this page...


That it says to migrate, I need to change to this:

var gridObj = document.getElementById('Grid').ej2_instances[0]
gridObj.getCurrentViewRecords();

However, "ej2_instances" isn't defined. How do I include this?

Thanks,
Dan


BS Balaji Sekar Syncfusion Team May 4, 2020 07:15 AM UTC

 
Greetings from the Syncfusion support. 
 
We have validated your query with provided the information and we suspect that you have undefined the grid id in the component wrapper. We can get the instance of the Grid using following code example with required highlighted code. 
 
[app.component.html] 
 <ejs-grid #grid [dataSource]='data'  allowFiltering='true' (dataBound)="onDataBound($event)" > 
</ejs-grid> 
 
[app.component.ts] 
 @ViewChild('grid') 
  public grid: GridComponent; 
 public buttonClick(args){ 
     var currentViewData = this.grid.getCurrentViewRecords();  
  console.log(currentViewData); 
    } 
 
 
 
We have achieved the filter operator in contains instead of startswith and you can download that sample as given below. 
 
 
Please get back to us, if you need further assistance. 
 
Regards, 
Balaji Sekar. 



DC Dan Clarke May 8, 2020 09:16 AM UTC

Thanks, this worked. Note that your solution doesn't match what your documentation says to do when migrating from EJ1 to EJ2. See the link in my previous post.


BS Balaji Sekar Syncfusion Team May 11, 2020 03:57 AM UTC

Hi Dan, 
 
Thanks for your update. 
 
We could see you would use the typescript documentation instead of Angular, since you have to face the mentioned problem. For EJ1 API migration in Angular Framework please refer to the documentation below. 
 

Regards, 
Balaji Sekar 


Loader.
Up arrow icon