@Html.EJS().Grid<gridmvclocalization.Controllers.OrdersDetails>
("Grid").DataSource((IEnumerable<object>
)ViewBag.dataSource).AllowPdfExport().AllowExcelExport().ToolbarClick("toolbarClick").Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Width("150").Add();
col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add();
col.Field("Freight").HeaderText("Freight").Width("160").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("140").Add();
}).AllowGrouping().GroupSettings(group => { group.Columns(new string[] { "ShipCountry" }).
CaptionTemplate("#captiontemplate"); }).AllowPaging().Aggregates(agg=> { agg.Columns(new List<Syncfusion.EJ2.Grids.GridAggregateColumn>() { new Syncfusion.EJ2.Grids.GridAggregateColumn() { Field = "Freight", Format = "C2", Type = "Average", GroupCaptionTemplate = "Average: ${Average}" } }).Add(); }).Toolbar(new List<string> () { "PdfExport", "ExcelExport" }).PageSettings(page => page.PageCount(2)).Render()
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_pdfexport') {
gridObj.pdfExport();
}
else if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
}
}
</script>
<script id="captiontemplate" type="text/x-template">
${field} - ${key}
</script> |
@Html.EJS().Grid<gridmvclocalization.Controllers.OrdersDetails>
("Grid").DataSource((IEnumerable<object>
)ViewBag.dataSource).AllowPdfExport().AllowExcelExport().ToolbarClick("toolbarClick").Columns(col =>
{
col.Field("OžrderID").HeaderText("OžrderID").Width("150").Add();
col.Field("CučstomerID").HeaderText("CučstomerID").Width("150").Add();
col.Field("Freight").HeaderText("Freight").Width("160").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
col.Field("ShipCountry").HeaderText("Ship Country").Width("140").Add();
}).AllowGrouping().GroupSettings(group => { group.Columns(new string[] { "ShipCountry" }).
CaptionTemplate("#captiontemplate"); }).AllowPaging()
.Aggregates(agg=> { agg.Columns(new List<Syncfusion.EJ2.Grids.GridAggregateColumn>() { new Syncfusion.EJ2.Grids.GridAggregateColumn() { Field = "Freight", Format = "C2", Type = "Average", GroupCaptionTemplate = "Average: ${Average}" } }).Add(); })
.Toolbar(new List<string>
() { "PdfExport", "ExcelExport" }).PageSettings(page => page.PageCount(2)).Render()
)
</div>
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_pdfexport') {
let pdfExportProperties = {
theme: {
header: { font: new ej.pdfexport.PdfTrueTypeFont(adventProFont, 12) },
caption: { font: new ej.pdfexport.PdfTrueTypeFont(adventProFont, 10) },
record: { font: new ej.pdfexport.PdfTrueTypeFont(adventProFont, 9) }
}
};
gridObj.pdfExport(pdfExportProperties);
}
else if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
}
}
var adventProFont = 'AAEAAAARAQAABAAQRFNJRwAAAAEAALa8AAAACEZGVE1fekHUAACnZAAAABxHREVGACgBwQAAp4AAAA………………………………………………………………………………………………………………………'
</script>
<script id="captiontemplate" type="text/x-template">
${field} - ${key}
</script>
|