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

Loop data/rows in grid

Thread ID:

Created:

Updated:

Platform:

Replies:

144552 May 11,2019 10:59 AM UTC May 16,2019 09:41 AM UTC Angular - EJ 2 7
loading
Tags: Grid
Jesus Sanchez
Asked On May 11, 2019 10:59 AM UTC

How to read all rows of my grid depending on the page in which we are and store them in my model (user.model)?

Thanks

Pavithra Subramaniyam [Syncfusion]
Replied On May 13, 2019 05:52 AM UTC

Hi Jesus, 
 
Thanks for contacting Syncfusion support.  
  
You can read the current page records by using  the “grid.currentViewData” property. Please refer to the below code example, documentation link and sample link for more information. 
 
[component.ts] 
@Component({ 
    selector: 'app-root', 
    template: '<button (click)="click($event)">Read records</button> 
    <ejs-grid #grid [dataSource]='data' allowPaging='true' height=365 [pageSettings]='initialPage'> 
        <e-columns> 
           .  .  . 
        </e-columns> 
    </ejs-grid> 
' 
}) 
export class AppComponent { 
    @ViewChild('grid') 
    public grid: GridComponent; 
 
    ngOnInit(): void { 
        this.data = data; 
        this.initialPage = { pageSizes: true, pageCount: 4 }; 
    } 
    click(e){ 
     console.log(this.grid.pageSettings.currentPage); 
     console.log(this.grid.currentViewData);            // here you can store the records in your model 
    } 
} 
 
                              https://ej2.syncfusion.com/angular/documentation/api/grid/pageSettingsModel/#currentpage 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


Jesus Sanchez
Replied On May 13, 2019 06:51 AM UTC

Thanksssss!!!!

Pavithra Subramaniyam [Syncfusion]
Replied On May 13, 2019 09:12 AM UTC

Hi Jesus, 
 
As always, we will be happy to assist you. 
 
Please contact us if you need any further assistance.  
 
Regards, 
Pavithra S. 


Jesus Sanchez
Replied On May 13, 2019 01:09 PM UTC

A question, advice ... imagine that we have stored images on the server site. In the example that you have: https://ej2.syncfusion.com/angular/demos/#/material/grid/column-template, if I wanted to recover the images of the site, how could I do it ???

Pavithra Subramaniyam [Syncfusion]
Replied On May 15, 2019 08:44 AM UTC

Hi Jesus, 

Thanks for the update. 

You can achieve your requirement by using the below way. 

Note: First You have to store the images in server as byte array. 

Step #1: You need to convert the byte array to base64 string. You can achieve this requirement like as following code snippet,  

string base64String = Convert.ToBase64String(bytes, 0, bytes.Length); // Convert the bytes to base64 string  

 

Step #2: You need to add this converted base64 string with Grid data source.  

Step #3: When you display the image in Grid to column, you need to convert this base64 string to image. We suggest you to use queryCellInfo event of the Grid to achieve this requirement. Please refer the following code snippet,  

function queryCellInfo(args) { // Grid queyCellInfo event  
        if (args.column.field == "Image") {  
           var image = new Image();  
            image.src = "data:image/png;base64," + args.data.Image; // base64 string  
            args.cell.appendChild(image); // Appended the image to particular cell  
        }  
    }  

 

In this code we have converted and appended the based64 string to Grid cell with the help of Grid queryCellInfo event. You can access the base64 string in this queryCellInfo event argument(i.e args.data). 


Please get back to us if you need further assistance. 
 
Regards, 
Pavithra S. 


Jesus Sanchez
Replied On May 16, 2019 08:30 AM UTC

Thanks ... now work it!!!!

Pavithra Subramaniyam [Syncfusion]
Replied On May 16, 2019 09:41 AM UTC

Hi Jesus,  

Thanks for your update. 

We are happy to hear that the provided solution works. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

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