@(Html.EJ().Grid<BitacoraR>("GridBitacorabyIngeniero") .Datasource((IEnumerable<BitacoraR>)ViewBag.BitacorabyIngeniero) .Locale("es-MX") .AllowPaging() .AllowScrolling() .CssClass("CustomCss") .PageSettings(p => { p.PageSize(16); }) .ScrollSettings(col => { col.Width(1150); }) .SelectionType(SelectionType.Multiple) .AllowSelection() .IsResponsive() .EnableResponsiveRow() .AllowFiltering() .FilterSettings(filter => { filter.FilterType(FilterType.Excel); }) .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.ExcelExport); items.AddTool(ToolBarItems.PrintGrid); }); }) .Columns(col => { col.Field("Id").IsPrimaryKey(true).Visible(false).Add(); col.Field("Date").HeaderText("Fecha").Format("{0:dd/MM/yyyy}").Width(110).TextAlign(TextAlign.Center).HeaderTextAlign(TextAlign.Left).Add(); col.Field("Nombre_Completo").HeaderText("Cliente").Width(147).TextAlign(TextAlign.Center).HeaderTextAlign(TextAlign.Left).Add(); col.Field("Nombre_Cliente").HeaderText("Cliente").Width(147).TextAlign(TextAlign.Center).HeaderTextAlign(TextAlign.Left).Add(); col.Field("Nombre_Locacion").HeaderText("Locación").Width(180).TextAlign(TextAlign.Left).HeaderTextAlign(TextAlign.Left).Add(); col.Field("Estatus").HeaderText("Estatus").Width(180).TextAlign(TextAlign.Center).HeaderTextAlign(TextAlign.Left).Add(); }) .ClientSideEvents(evt => evt.ToolbarClick("OnToolbarClick")) ) |
function OnToolbarClick(args) { if (args.itemName.indexOf("Print") > -1) {//if no selectedRecords, currenviewdata will be exported var currentData = JSON.stringify(this.model.selectedRecords.length == 0 ? this.model.currentViewData : this.model.selectedRecords); args.cancel = true; ej.print(currentData); } if (args.itemName.indexOf("Export") > -1) {//if no selectedRecords, currenviewdata will be exported this.model["currentData"] = JSON.stringify(this.model.selectedRecords.length == 0 ? this.model.currentViewData : this.model.selectedRecords); } } |
@(Html.EJ().Grid<OrdersView>("Grid")
.AllowPaging()
.ToolbarSettings(tools =>
{
tools.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.PrintGrid);
});
})
.ClientSideEvents(events => events.BeforePrint("onBeforePrint"))
)
<script>
function onBeforePrint(args){
var gridInst = $("#Grid").ejGrid("instance");
var selRows = gridInst.getContentTable().find('tr[aria-selected="true"]');
args.element.find(".e-gridcontent tbody tr").remove();
args.element.find(".e-gridcontent tbody").append(selRows);
gridInst.refreshContent();
}
</script> |
@(Html.EJ().Grid<OrdersView>("Grid")
.AllowPaging()
.ToolbarSettings(tools =>
{
tools.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.PrintGrid);
});
})
.ClientSideEvents(events => events.BeforePrint("onBeforePrint").ActionBegin("actionBegin"))
)
<script type="text/javascript">
window.selectedRows = [];
function printSelectedRows(selRows) {
if (!selectedRows.length) selectedRows = selRows;
else {
for (var sr = 0; sr < selRows.length; sr++) {
selectedRows.push(selRows[sr]);
}
}
}
function actionBegin(args) {
if (args.requestType == "paging") {
if (this.getSelectedRows().length) {
var selRows = this.getSelectedRows();
printSelectedRows(selRows);
}
}
}
function beforePrint(args) {
var gridInst = $("#Grid").ejGrid("instance");
var selRows = gridInst.getContentTable().find('tr[aria-selected="true"]');
if (selectedRows.length || selRows.length) {
if (selRows.length) printSelectedRows(selRows);
args.element.find(".e-gridcontent tbody tr").remove();
args.element.find(".e-gridcontent tbody").append(selectedRows);
gridInst.refreshContent();
}
}
</script> |