Hi,
I can't find the sample code for blazor grid.
|
<GridEvents OnToolbarClick="ToolbarClickHandler" PdfQueryCellInfoEvent="PdfQueryCellInfoEvent" ExcelQueryCellInfoEvent="ExcelQueryCellInfoEvent" TValue="Order"></GridEvents>
public async Task ToolbarClickHandler(Syncfusion.Blazor.Navigations.ClickEventArgs args)
{
if (args.Item.Id == "Grid_pdfexport") //Id is combination of Grid's ID and itemname
{
PdfExportProperties pdfExportProperties = new PdfExportProperties();
pdfExportProperties.IncludeTemplateColumn = true;
await this.DefaultGrid.PdfExport(pdfExportProperties);
}
if (args.Item.Id == "Grid_excelexport") //Id is combination of Grid's ID and itemname
{
ExcelExportProperties excelExportProperties = new ExcelExportProperties();
excelExportProperties.IncludeTemplateColumn = true;
await this.DefaultGrid.ExcelExport(excelExportProperties);
}
}
|
|
public void ExcelQueryCellInfoEvent(ExcelQueryCellInfoEventArgs<Order> args)
{
...
if (args.Column.HeaderText == "Customer Name")
{
args.Cell.Value = "<a rel='nofollow' href=\'https:\\www.google.com'>" + @args.Data.CustomerID + "</a>";
}
}
|
|
public void PdfQueryCellInfoEvent(PdfQueryCellInfoEventArgs<Order> args)
{
if (args.Column.HeaderText == "Order ID")
{
Image img = Image.FromFile(@"wwwroot/Images/Uploads/" + args.Data.OrderID.ToString() + ".png");
byte[] bytes = (byte[])(new ImageConverter()).ConvertTo(img, typeof(byte[]));
//use the byte to generate a base64String and assign to image to get displayed in Grid
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
byte[] dataString = Convert.FromBase64String(base64String);
System.IO.MemoryStream imageStream = new System.IO.MemoryStream(dataString);
args.Cell.Style.BackgroundImage = Syncfusion.PdfExport.PdfImage.FromStream(imageStream);
args.Cell.ImagePosition = Syncfusion.PdfExport.PdfGridImagePosition.Center;
}
...
}
|