...
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Columns(col =>
{
...
}).AllowPaging().AllowExcelExport().AllowPdfExport().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() { "Add", "Edit", "Update", "Delete", "Cancel" }).Render()
<div class="e-grid">
@Html.EJS().Toolbar("defaultToolbar").Items(new List<Syncfusion.EJ2.Navigations.ToolbarItem> {
new Syncfusion.EJ2.Navigations.ToolbarItem { Id= "excel", Type = Syncfusion.EJ2.Navigations.ItemType.Button, Text = "ExcelExport", PrefixIcon= "e-excelexport" },
new Syncfusion.EJ2.Navigations.ToolbarItem { Id= "pdf", Type = Syncfusion.EJ2.Navigations.ItemType.Button, Text = "PdfExport", PrefixIcon= "e-pdfexport"},
}).Clicked("toolbarClick").Render()
</div>
<script>
function toolbarClick(args) {
var grid = document.getElementById("Grid").ej2_instances[0];
if (args.item.id == "excel") {
grid.excelExport();
}
else if (args.item.id == "pdf") {
grid.pdfExport();
}
}
</script>
... |
@(Html.EJ().Grid<OrdersView>("Grid")
.Datasource((IEnumerable<object>)ViewBag.datasource)
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.ToolbarSettings(toolbar =>{
toolbar.ShowToolbar().ToolbarItems(items => {
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
});
})
.Columns(col =>{
. . .
})
)
@Html.EJ().Toolbar("editingToolbar").Items(s =>{
s.Add().SpriteCssClass("e-icon e-addnew").TooltipText("add");
s.Add().SpriteCssClass("e-icon e-edit").TooltipText("edit");
}).Width("100%").EnableSeparator(true).Height("25px").ClientSideEvents(eve => eve.Click("click"))
<style>
.material .frame {
width: 497px;
}
</style>
<script type="text/javascript">
function click(args) {
var gridObj = $("#Grid").ejGrid("instance");
if (args.text == "add") {
gridObj.addRecord();
}
else if (args.text == "edit") {
var inx = gridObj.model.selectedRowIndex;
var row = gridObj.getRowByIndex(6);
gridObj.startEdit(row);
}
}
</script>
|