@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
. . .
}).AllowPaging().AllowGrouping().DataBound("dataBound").Toolbar(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" }).Render()
<script>
var initialGridLoad = true;
function dataBound() {
if (initialGridLoad) {
var topElement;
initialGridLoad = false;
var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0];
var pager = document.getElementsByClassName('e-gridpager');
if (grid.allowGrouping || grid.toolbar) {
topElement = grid.allowGrouping ? document.getElementsByClassName('e-groupdroparea') :
document.getElementsByClassName('e-toolbar');
} else {
topElement = document.getElementsByClassName('e-gridheader');
}
grid.element.insertBefore(pager[0], topElement[0]);
}
}
</script> |
@Html.EJS().Grid("Grid")...DataBound("dataBound")...Render()
<script>
var initialGridLoad = true;
function dataBound() {
if (initialGridLoad) {
initialGridLoad = false;
var toolobj = document.getElementsByClassName("e-toolbar")[0].ej2_instances[0]; //Get instance of toolbar
toolobj.height = "60px" //Set the height for the toolbar as required
var toolbar = document.getElementsByClassName('e-toolbar-items')[0];
toolbar.classList.add("e-tbar-pos"); //add “e-tbar-pos” class in toolbar element
var pagesizedrop = document.getElementsByClassName('e-pagesizes')[0];
pagesizedrop.classList.add("e-toolbar-right"); //add “e-toolbar-right” class to pagesize element
//append the page size drop down to toolbar
toolbar.appendChild(pagesizedrop);
}
}
</script> |