|
@(Html.EJ().Grid<object>("FlatGrid")
.Datasource((IEnumerable<object>)ViewBag.DataSource)
.AllowPaging()
.AllowGrouping()
.ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.ExcelExport);
}))
.Locale("de-DE")
. .
)
</div>
<script>
ej.Grid.Locale["de-DE"] = {
. . .
. ..
GroupCaptionFormat: "{{:field}}: {{:key}} - {{:count}} {{if key == 1}}Material{{else}}Materialien{{/if}}",
};
</script>
[CS]
public class GridController : Controller
{
//
// GET: /Grid/
public ActionResult GridFeatures()
{
var DataSource = new NorthwindDataContext().OrdersViews.ToList();
ViewBag.datasource = DataSource;
return View();
}
public void ExportToExcel(string GridModel)
{
GridExcelExport exp1 = new GridExcelExport();
ExcelExport exp = new ExcelExport();
var DataSource = new NorthwindDataContext().OrdersViews.ToList();
GridProperties obj = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties), GridModel);
obj.ServerExcelGroupCaptionInfo = captioninfo;
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron");
}
protected void captioninfo(object obj) {
CaptionFormatEventArgs e = (CaptionFormatEventArgs)obj;
if((int)e.Context.Key == 1)
{
e.GroupCaptionTemplate = e.GroupedColum.Field + ":" + e.Context.Key + "-" + e.Context.Count + " Material";
}
else
e.GroupCaptionTemplate = e.GroupedColum.Field + " :" + e.Context.Key + "-" + e.Context.Count + " Materialien";
}
}
}
|