|
<script>
// Grid's toolbarClick event
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_pdfexport') {
gridObj.pdfExport();
}
}
//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.
function queryCellInfo(args) {// Grid's queryCellInfo event
if (args.column.field == "Image") {
args.cell.querySelector('img').setAttribute('src', 'data:image/jpeg;base64 ,' + args.data.Image);
args.cell.querySelector('img').setAttribute('width', 150);
args.cell.querySelector('img').setAttribute('height', 150);
}
}
// Grid's pdfQueryCellInfo event
function pdfQueryCellInfo(args) {
if (args.column.headerText == 'Image') {
args.value = new ej.pdfexport.PdfBitmap(args.data.Image); // pass base64 of jpeg
for (var i = 0; i < args.cell.gridRow.pdfGrid.rows.rows.length; i++) {
args.cell.gridRow.pdfGrid.rows.getRow(i).height = "50"; //set height
}
}
}
</script> |