public ActionResult DataSource(DataManager dataManager) { IEnumerable data = new List <MediaTypeViewModel>(); int countAll = 0; ZOperationResult operationResult = new ZOperationResult(); if (IsSearch()) { try { SyncfusionGrid syncfusionGrid = new SyncfusionGrid(typeof(MediaType), UnitOfWork.DBMS); ArrayList args = new ArrayList(); string where = syncfusionGrid.ToLinqWhere(dataManager.Search, dataManager.Where, args); string orderBy = syncfusionGrid.ToLinqOrderBy(dataManager.Sorted); int take = (dataManager.Skip == 0 && dataManager.Take == 0) ? AppDefaults.SyncfusionRecordsBySearch : dataManager.Take; // Excel Filtering data = ZViewHelper <MediaTypeViewModel, MediaTypeDTO, MediaType> .ToViewList(Repository.Select(where, args.ToArray(), orderBy, dataManager.Skip, take)); if (dataManager.RequiresCounts) { countAll = Repository.Count(where, args.ToArray()); } } catch (Exception exception) { operationResult.ParseException(exception); } if (!operationResult.Ok) { throw new InvalidOperationException(operationResult.Text); } } return(Json(JsonConvert.SerializeObject(new { result = data, count = countAll }), JsonRequestBehavior.AllowGet)); }
protected void ExportToWord(string gridModel, string fileName) { ZOperationResult operationResult = new ZOperationResult(); try { if (IsExport(operationResult)) { IEnumerable data = Application.SearchAll(operationResult); if (operationResult.Ok) { SyncfusionGrid.ExportToWord(gridModel, data, fileName, AppDefaults.SyncfusionTheme); } } } catch (Exception exception) { operationResult.ParseException(exception); } if (!operationResult.Ok) { gridModel = "{\"columns\":[{\"field\":\"Message\",\"headerText\":\"" + ErrorResources.Error + "\"}]}"; SyncfusionGrid.ExportToWord(gridModel, operationResult.ToDataSet(), fileName, AppDefaults.SyncfusionTheme); } }
protected void ExportToExcel(string gridModel, IEnumerable data, string theme, string fileName) { GridProperties gridProperties = SyncfusionGrid.ModelToObject(gridModel); ExcelExport export = new ExcelExport(); IWorkbook excel = export.Export(gridProperties, data, fileName, ExcelVersion.Excel2013, false, false, theme, true); excel.ActiveSheet.DeleteRow(1, 1); excel.SaveAs(fileName, ExcelSaveType.SaveAsXLS, System.Web.HttpContext.Current.Response, ExcelDownloadType.Open); //excel.SaveAs(fileName, ExcelSaveType.SaveAsXLS, Controller.Response, ExcelDownloadType.Open); }
private void GridView_Unloaded(object sender, RoutedEventArgs e) { if (SyncfusionGrid != null) { SyncfusionGrid.Dispose(); SyncfusionGrid = null; } if (comboBoxAdv != null) { comboBoxAdv.Dispose(); comboBoxAdv = null; } if (sfDataPager != null) { sfDataPager.Dispose(); sfDataPager = null; } this.Unloaded -= GridView_Unloaded; }
public ActionResult DataSource(DataManager dataManager) { SyncfusionDataResult dataResult = new SyncfusionDataResult(); dataResult.result = new List <UserClaimViewModel>(); ZOperationResult operationResult = new ZOperationResult(); if (IsSearch(operationResult)) { try { SyncfusionGrid syncfusionGrid = new SyncfusionGrid(typeof(UserClaim), Application.UnitOfWork.DBMS); ArrayList args = new ArrayList(); string where = syncfusionGrid.ToLinqWhere(dataManager.Search, dataManager.Where, args); string orderBy = syncfusionGrid.ToLinqOrderBy(dataManager.Sorted); int take = (dataManager.Skip == 0 && dataManager.Take == 0) ? AppDefaults.SyncfusionRecordsBySearch : dataManager.Take; // Excel Filtering dataResult.result = ZViewHelper <UserClaimViewModel, UserClaim> .ToViewList(Application.Search(operationResult, where, args.ToArray(), orderBy, dataManager.Skip, take)); if (dataManager.RequiresCounts) { dataResult.count = Application.Count(operationResult, where, args.ToArray()); } } catch (Exception exception) { operationResult.ParseException(exception); } if (!operationResult.Ok) { throw operationResult.Exception; } } return(Json(JsonConvert.SerializeObject(dataResult), JsonRequestBehavior.AllowGet)); }