@{
ViewBag.Title = "Grid Sample";
}
<div>
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).AllowPdfExport().PdfQueryCellInfo("PdfQueryCellInfo").
ExcelQueryCellInfo("ExcelQueryCellInfo").AllowExcelExport().ToolbarClick("toolbarClick").Columns(col =>
{
...
col.HeaderText("TemplateColumn").Width("150").Template("#template").Add();
}).AllowPaging().PageSettings(page => page.PageSize(8)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true)
.Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel", "ExcelExport", "PdfExport" }).Render()
</div>
<script id="template" type="text/template">
<div>
${ShipCountry}, ${ShipCity}
</div>
</script>
<script>
function toolbarClick(args) {
var gridObj = document.getElementById("Grid").ej2_instances[0];
if (args.item.id === 'Grid_excelexport') {
gridObj.excelExport();
} else if (args.item.id === 'Grid_pdfexport') {
gridObj.pdfExport();
}
}
function ExcelQueryCellInfo(args) {
if (args.value.length === 0) {
args.value = args.data.ShipCountry + ", " + args.data.ShipCity;
}
}
function PdfQueryCellInfo(args) {
if (args.value.length === 0) {
args.value = args.data.ShipCountry + ", " + args.data.ShipCity;
}
}
</script> |