BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<head>
<title>Essential Studio for JavaScript : Inline on Local data</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<link rel='nofollow' href="../css/default-theme/ej.widgets.all.min.css" rel="stylesheet" />
<script src="../external/jquery-2.1.4.min.js"></script>
<script src="../external/jquery.easing.1.3.min.js"></script>
<script src="../external/jsondata.min.js"></script>
<script src="../external/jsrender.min.js"></script>
<script src="../external/ej.web.all.min.js"></script> </head> |
@{ ViewBag.Title = "Grid"; Layout = null; IEnumerable<object> dataSource = (IEnumerable<object>)ViewBag.datasource; List<Column> cols = (List<Column>)ViewBag.columns; }
@(Html.EJ().Grid<StudentTestScores>("gvStudentsScores") .Datasource(ds => ds.Json(dataSource).Adaptor(AdaptorType.JsonAdaptor)) .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.ExcelExport); items.AddTool(ToolBarItems.WordExport); items.AddTool(ToolBarItems.PdfExport); items.AddTool(ToolBarItems.PrintGrid); })) .AllowSorting() .AllowPaging() .PageSettings(page => { page.PageSize(20); }) .Columns(cols) ) @Html.EJ().ScriptManager()
[OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] public PartialViewResult GetReport(string[] ids, string year, string schoolCode, string schoolGrade, int? page, string[] demoIds) { var ds = GetStudentsScoresData(ids, year, schoolCode, schoolGrade, demoIds); ViewBag.datasource = ds.ToList(); //return PartialView("_GridView", GetStudentsScoresData(ids, year, schoolCode, schoolGrade, demoIds)); return PartialView("_GridView"); } // end of PartialViewResult GetReport
public IEnumerable<object> GetStudentsScoresData(string[] ids, string year, string schoolCode, string schoolGrade, string[] demoIds) { StudentRepository studentRepository = new StudentRepository(); IEnumerable<StudentTestScores> students = new List<StudentTestScores>(); if (ids != null && demoIds == null) { var selectedIds = string.Join(",", ids); students = studentRepository.GetStudentData(selectedIds, year, schoolCode, schoolGrade); } else if (ids != null && demoIds != null) { var selectedIds = string.Join(",", ids); var selectedDemoIds = string.Join(",", demoIds); students = studentRepository.GetStudentTestScoreAndDemographicsData(selectedIds, year, schoolCode, schoolGrade, selectedDemoIds); } else { students = studentRepository.GetAll(); //studentRepository.GetAll(); } StudentTestScores studentTestScore = students.First(); Type modelType = studentTestScore.GetType(); IList<PropertyInfo> props = new List<PropertyInfo>(modelType.GetProperties()); IList<object> dataSource = new List<object>(); IList<string> headers = new List<string>(); foreach (StudentTestScores sts in students) { Dictionary<string, string> dic = new Dictionary<string, string>(); foreach (PropertyInfo prop in props) { string propName = prop.Name; var val = prop.GetValue(sts, null); if (val != null && propName != "StudNo" && propName != "SchoolYear" && propName != "Data") { string header = propName; string myType = val.GetType().Name.ToString(); if (myType.ToLower().Contains("list")) // this is ScoreInfo { var scoreInfoLst = (List<ScoreInfo>)val; if (scoreInfoLst.Count > 0) { ScoreInfo scoreInfo = scoreInfoLst[0]; header = String.Format("{0} {1} {2}", scoreInfo.SubjectName, scoreInfo.AdministrationName, propName); dic.Add(header, scoreInfo.Score.ToString()); if (!headers.Contains(header)) { headers.Add(header); } } } else { if (header == "FirstName") header = "First Name"; if (header == "LastName") header = "Last Name"; dic.Add(header, val.ToString()); if (!headers.Contains(header)) { headers.Add(header); } } } } dataSource.Add((object)dic); } List<Column> cols = new List<Column>(); foreach (string h in headers) { cols.Add(new Column() { Field = h, HeaderText = h }); } ViewBag.columns = cols; return (IEnumerable<object>)dataSource; } // end of GetStudentsScoresData