We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error in Ej.export.dll when calling from grid

Hi,

I have grid with custom columns that are populated on demand.


<div id="gridPanelDetailsMaintenance" class="row">
            @(Html.EJ().Grid<DocTracerPortal.Models.Visual.VisualGridDocument>("GridDocumentMaintenance")
                 .Datasource((IEnumerable<DocTracerPortal.Models.Visual.VisualGridDocument>)ViewBag.documentVisualResultsSource)
                 .AllowSorting()
                 .IsResponsive(true)
                 .AllowSelection(true)
                 .AllowResizeToFit(true)
                 .ShowColumnChooser()
                 .AllowGrouping()
                 .SelectionType(SelectionType.Multiple)
                 .SelectionSettings(select => { select.SelectionMode(mode => { mode.AddMode(SelectionMode.Row); }); })
                 .ContextMenuSettings(contextMenu =>
                 {
                     contextMenu.EnableContextMenu().DisableDefaultItems(true)
                         .CustomContextMenuItems(new List<Syncfusion.JavaScript.Models.CustomContexMenuItems>() {
                                                                                    new  Syncfusion.JavaScript.Models.CustomContexMenuItems() { Id = "1", Text = "Edit properties (all) <img src='/Images/grid_DocumentDetails/options/edit.png' style='width:20px;height:20px' />" } ,
                                                                                    new  Syncfusion.JavaScript.Models.CustomContexMenuItems() { Id = "2", Text = "Server Storage View <img src='/Images/grid_DocumentDetails/options/Dashboard.png' style='width:20px;height:20px' />" } ,
                                                                                    //new  Syncfusion.JavaScript.Models.CustomContexMenuItems() { Id = "3", Text = "Show Versions of This Document only <img src='/Images/grid_DocumentDetails/options/find-16x16.png' style='width:20px;height:20px' />" } ,//Not for MVP
                                                                                    new  Syncfusion.JavaScript.Models.CustomContexMenuItems() { Id = "4", Text = "Assign Group Security <img src='/Images/grid_DocumentDetails/options/securityAssignment_16px.png' style='width:20px;height:20px' />" } ,
                                                                                     }); // CustomContext menu items

                 })
                 .ClientSideEvents(eve =>
                 {
                     eve.ContextClick("contextClickMaintenance").ContextOpen("contextOpenMaintenance").RecordClick("rowSelectMaintenance");
                     eve.ActionComplete("actionComplete").RecordDoubleClick("rdoubleClickMaintenance");
                     eve.ActionComplete("completeMaintenance");
                 })
                 .EditSettings(edit =>
                 {
                     edit.AllowDeleting().AllowEditing().EditMode(EditMode.DialogTemplate).TitleColumn("Name").DialogEditorTemplateID("#templateMaintenance");
                 })
                 .ToolbarSettings(toolbar =>
                 {
                     toolbar.ShowToolbar().ToolbarItems(items =>
                     {
                         items.AddTool(ToolBarItems.Edit);
                         items.AddTool(ToolBarItems.Delete);
                         items.AddTool(ToolBarItems.Update);
                         items.AddTool(ToolBarItems.Cancel);
                         items.AddTool(ToolBarItems.PrintGrid);
                         items.AddTool(ToolBarItems.ExcelExport);
                         items.AddTool(ToolBarItems.WordExport);
                         items.AddTool(ToolBarItems.PdfExport);
                     });
                 })
                 .Mappers(map => map.ExportToExcelAction("/Default/ExportToExcel").ExportToPdfAction("/Default/ExportToPdf").ExportToWordAction("/Default/ExportToWord"))
                 .AllowResizing(true)
                 //.AllowPaging()
                 .AllowFiltering()
                 //.FilterSettings(filter => { filter.FilterType(FilterType.Excel); })
                 .FilterSettings(filter => { filter.FilterType(FilterType.Menu); })
                 //.FilterSettings(d => d.FilterType(FilterType.FilterBar))
                 .Columns(col =>
                 {
                     col.Field(p => p.Id).HeaderText("Document Id").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Visible(false).Add();
                     col.HeaderText("In/Out").Template("#ColumnStatus").TextAlign(TextAlign.Center).Add();
                     col.HeaderText("Options").Template("#ColumnOption").TextAlign(TextAlign.Left).Add();
                     col.HeaderText("Ver").Template("#ColumnVersionsMaintenance").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.DocumentNumber).Tooltip("#colTip").HeaderText("Document #").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.Name).HeaderText("File Name").Tooltip("#colTip").AllowEditing(false).TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.DocumentTitle).HeaderText("Document Title").Tooltip("#colTip").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.PageSizeId).HeaderText("PageSize ID").EditType(EditingType.Dropdown).TextAlign(TextAlign.Right).Visible(false).Width(75).Add();
                     col.Field(p => p.PageSize).Tooltip("#colTip").HeaderText("Page Size").TextAlign(TextAlign.Left).EditType(EditingType.Dropdown).Add();
                     col.Field(p => p.DocumentRevisionNumber).Tooltip("#colTip").HeaderText("Revision #").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.TransmittalNumber).Tooltip("#colTip").HeaderText("Transmittal Number").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.OriginalSizeMB).Tooltip("#colTip").HeaderText("Size").AllowEditing(false).TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.DateUploaded).Tooltip("#colTip").HeaderText("Date Created").AllowEditing(false).TextAlign(TextAlign.Left).Format("{0:MM/dd/yyyy hh:mm:ss}").Add();
                     col.Field(p => p.DateReceivedString).Tooltip("#colTip").HeaderText("Date Received").AllowEditing(false).TextAlign(TextAlign.Left).Format("{0:MM/dd/yyyy hh:mm:ss}").Add();
                     col.Field(p => p.UploadedBy).HeaderText("Uploaded By").TextAlign(TextAlign.Left).AllowEditing(false).Add();
                     col.Field(p => p.Tags).Tooltip("#colTip").HeaderText("Tags").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.Comments).Tooltip("#colTip").HeaderText("Comments").TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.AreaId).HeaderText("Area ID").EditType(EditingType.Dropdown).TextAlign(TextAlign.Right).Visible(false).Width(75).Add();
                     col.Field(p => p.AreaName).Tooltip("#colTip").HeaderText("Area").TextAlign(TextAlign.Left).EditType(EditingType.Dropdown).Add();
                     col.Field(p => p.DocumentCategoryId).HeaderText("Document Category ID").EditType(EditingType.Dropdown).Visible(false).TextAlign(TextAlign.Right).Width(75).Add();
                     col.Field(p => p.DocumentCategoryName).Tooltip("#colTip").HeaderText("Category").TextAlign(TextAlign.Left).EditType(EditingType.Dropdown).Add();
                     col.Field(p => p.DocumentStatusId).HeaderText("Document Status ID").EditType(EditingType.Dropdown).Visible(false).TextAlign(TextAlign.Right).Width(75).Add();
                     col.Field(p => p.DocumentStatusName).Tooltip("#colTip").HeaderText("Document Status").TextAlign(TextAlign.Left).EditType(EditingType.Dropdown).Add();
                     col.Field(p => p.Extension).Tooltip("#colTip").HeaderText("Ext").AllowEditing(false).TextAlign(TextAlign.Left).Add();
                     col.Field(p => p.NumberOfPages).Tooltip("#colTip").HeaderText("Pages").EditType(EditingType.Numeric).TextAlign(TextAlign.Right).Add();
                     //col.Field(p => p.ForceCheckIn).HeaderText("Force check in").TextAlign(TextAlign.Left).Add();
                     //col.Field(p => p.ReadOnly).HeaderText("Read Only").TextAlign(TextAlign.Left).Add();
                 })
            )
        </div>

The grid works fine. However, I have issues with the export methods. I'm getting this error in the call



The stack trace of the error is

   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordCell(Object row, Column column)
   at Syncfusion.EJ.Export.GridExcelExport.<>c__DisplayClasse.<ProcessRecordRow>b__d(Column column)
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Syncfusion.EJ.Export.GridExcelExport.ProcessRecordRow(Object row)
   at Syncfusion.EJ.Export.GridExcelExport.RenderRecord()
   at Syncfusion.EJ.Export.GridExcelExport.ProcessGridContents()
   at Syncfusion.EJ.Export.GridExcelExport.IterateElements()
   at Syncfusion.EJ.Export.GridExcelExport.ExportHandler()
   at Syncfusion.EJ.Export.GridExcelExport.ExecuteResult(GridProperties GridModel, Object dataSource)
   at Syncfusion.EJ.Export.GridExcelExport.ExportHelper(GridProperties gridModel, Object dataSource)
   at Syncfusion.EJ.Export.GridExcelExport.Export(GridProperties gridModel, Object dataSource, Boolean multipleExport)
   at Syncfusion.EJ.Export.ExcelExport.Export(GridProperties gridmaodel, Object datasource, String excelname, ExcelVersion excelversion, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, String theme)
   at Syncfusion.EJ.Export.ExcelExport.Export(GridProperties gridmaodel, IEnumerable datasource, String excelname, ExcelVersion excelversion, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, String theme)
   at DocTracerPortal.Controllers.Maintenance.DefaultController.ExportToExcel(String GridModel) in D:\CodeBitbucket\doctracerportal\DocTracerPortal\Controllers\Maintenance\DefaultController.cs:line 627

I checked the objects that are passed to the Export method and they are populated.

Model

"{\"allowPaging\":false,\"showColumnChooser\":true,\"gridLines\":\"both\",\"allowSorting\":true,\"showStackedHeader\":false,\"selectedRecords\":[],\"stackedHeaderRows\":[],\"allowFiltering\":true,\"allowMultipleExporting\":false,\"allowSelection\":true,\"allowGrouping\":true,\"showSummary\":false,\"allowResizing\":true,\"allowResizeToFit\":true,\"allowTextWrap\":false,\"allowCellMerging\":false,\"enablePersistence\":false,\"enableFocusout\":false,\"selectedRowIndex\":-1,\"allowSearching\":false,\"enableToolbarItems\":false,\"allowReordering\":false,\"allowRowDragAndDrop\":false,\"enableTouch\":true,\"columnLayout\":\"auto\",\"locale\":\"en-US{\\\"EmptyRecord\\\":\\\"No records to display\\\",\\\"GroupCaptionFormat\\\":\\\"{{:headerText}}: {{:key}} - {{:count}} \\\",\\\"GroupText\\\":\\\" item\\\",\\\"True\\\":\\\"true\\\",\\\"False\\\":\\\"false\\\"}\",\"allowMultiSorting\":false,\"exportToExcelAction\":\"/Default/ExportToExcel\",\"exportToWordAction\":\"/Default/ExportToWord\",\"exportToPdfAction\":\"/Default/ExportToPdf\",\"_groupingCollapsed\":[],\"selectionSettings\":{\"selectionMode\":[\"row\"],\"enableToggle\":false,\"cellSelectionMode\":\"flow\"},\"resizeSettings\":{\"resizeMode\":\"nextcolumn\"},\"groupSettings\":{\"showDropArea\":true,\"showToggleButton\":false,\"showGroupedColumn\":true,\"showUngroupButton\":true,\"enableDropAreaAutoSizing\":true,\"captionFormat\":null,\"groupedColumns\":[]},\"contextMenuSettings\":{\"enableContextMenu\":true,\"contextMenuItems\":[\"Add Record\",\"Edit Record\",\"Delete Record\",\"Sort In Ascending Order\",\"Sort In Descending Order\",\"Next Page\",\"Last Page\",\"Previous Page\",\"First Page\",\"Save\",\"Cancel\",\"Grouping\",\"Ungrouping\"],\"customContextMenuItems\":[{\"id\":\"1\",\"text\":\"Edit properties (all) <img src='/Images/grid_DocumentDetails/options/edit.png' style='width:20px;height:20px' />\"},{\"id\":\"2\",\"text\":\"Server Storage View <img src='/Images/grid_DocumentDetails/options/Dashboard.png' style='width:20px;height:20px' />\"},{\"id\":\"4\",\"text\":\"Assign Group Security <img src='/Images/grid_DocumentDetails/options/securityAssignment_16px.png' style='width:20px;height:20px' />\"}],\"subContextMenu\":[],\"disableDefaultItems\":true},\"filterSettings\":{\"filterType\":\"menu\",\"filterBarMode\":\"immediate\",\"showFilterBarStatus\":true,\"statusBarWidth\":450,\"showPredicate\":false,\"filteredColumns\":[],\"enableInterDeterminateState\":true,\"maxFilterChoices\":1000,\"enableCaseSensitivity\":false,\"immediateModeDelay\":1500,\"enableComplexBlankFilter\":true,\"blankValue\":\"\"},\"searchSettings\":{\"fields\":[],\"key\":\"\",\"operator\":\"contains\",\"ignoreCase\":true},\"sortSettings\":{\"sortedColumns\":[]},\"toolbarSettings\":{\"showToolbar\":true,\"toolbarItems\":[\"edit\",\"delete\",\"update\",\"cancel\",\"printGrid\",\"excelExport\",\"wordExport\",\"pdfExport\"],\"customToolbarItems\":[]},\"minWidth\":0,\"currentIndex\":0,\"rowDropSettings\":{\"dropMapper\":null,\"dragMapper\":null,\"dropTargetID\":null},\"scrollSettings\":{\"width\":1560,\"height\":0,\"enableTouchScroll\":true,\"allowVirtualScrolling\":false,\"virtualScrollMode\":\"normal\",\"frozenRows\":0,\"frozenColumns\":0,\"buttonSize\":18,\"autoHide\":false,\"scrollerSize\":18,\"scrollOneStepBy\":57,\"enableVirtualization\":false},\"textWrapSettings\":{\"wrapMode\":\"both\"},\"summaryRows\":[],\"enableRTL\":false,\"enableAltRow\":true,\"childGrid\":null,\"keySettings\":null,\"mergeCellInfo\":null,\"create\":null,\"actionBegin\":null,\"actionComplete\":\"completeMaintenance\",\"actionFailure\":null,\"beginEdit\":null,\"endEdit\":null,\"endAdd\":null,\"endDelete\":null,\"beforeBatchAdd\":null,\"beforeBatchSave\":null,\"beforeBatchDelete\":null,\"batchAdd\":null,\"batchDelete\":null,\"cellSave\":null,\"cellEdit\":null,\"resizeStart\":null,\"resizeEnd\":null,\"resized\":null,\"load\":null,\"destroy\":null,\"rowSelecting\":null,\"rowSelected\":null,\"cellSelecting\":null,\"cellSelected\":null,\"columnSelecting\":null,\"columnSelected\":null,\"columnDragStart\":null,\"columnDrag\":null,\"columnDrop\":null,\"dataBound\":null,\"recordClick\":\"rowSelectMaintenance\",\"recordDoubleClick\":\"rdoubleClickMaintenance\",\"templateRefresh\":null,\"rightClick\":null,\"detailsCollapse\":null,\"detailsExpand\":null,\"contextOpen\":\"contextOpenMaintenance\",\"contextClick\":\"contextClickMaintenance\",\"columns\":[{\"field\":\"Id\",\"headerText\":\"Document Id\",\"textAlign\":\"right\",\"isPrimaryKey\":true,\"visible\":false,\"width\":75,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"string\"},{\"field\":\"\",\"headerText\":\"In/Out\",\"template\":\"#ColumnStatus\",\"textAlign\":\"center\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"allowSorting\":false,\"allowFiltering\":false,\"allowGrouping\":false,\"type\":null},{\"field\":\"\",\"headerText\":\"Options\",\"template\":\"#ColumnOption\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"allowSorting\":false,\"allowFiltering\":false,\"allowGrouping\":false,\"textAlign\":\"left\",\"type\":null},{\"field\":\"\",\"headerText\":\"Ver\",\"template\":\"#ColumnVersionsMaintenance\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"allowSorting\":false,\"allowFiltering\":false,\"allowGrouping\":false,\"textAlign\":\"left\",\"type\":null},{\"field\":\"DocumentNumber\",\"headerText\":\"Document #\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"Name\",\"headerText\":\"File Name\",\"allowEditing\":false,\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DocumentTitle\",\"headerText\":\"Document Title\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"PageSizeId\",\"headerText\":\"PageSize ID\",\"editType\":\"dropdown\",\"textAlign\":\"right\",\"visible\":false,\"width\":75,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"number\"},{\"field\":\"PageSize\",\"headerText\":\"Page Size\",\"editType\":\"dropdown\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DocumentRevisionNumber\",\"headerText\":\"Revision #\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"TransmittalNumber\",\"headerText\":\"Transmittal Number\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"OriginalSizeMB\",\"headerText\":\"Size\",\"allowEditing\":false,\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DateUploaded\",\"headerText\":\"Date Created\",\"allowEditing\":false,\"format\":\"{0:MM/dd/yyyy hh:mm:ss}\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DateReceivedString\",\"headerText\":\"Date Received\",\"allowEditing\":false,\"format\":\"{0:MM/dd/yyyy hh:mm:ss}\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"UploadedBy\",\"headerText\":\"Uploaded By\",\"allowEditing\":false,\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"Tags\",\"headerText\":\"Tags\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"Comments\",\"headerText\":\"Comments\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"AreaId\",\"headerText\":\"Area ID\",\"editType\":\"dropdown\",\"textAlign\":\"right\",\"visible\":false,\"width\":75,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"number\"},{\"field\":\"AreaName\",\"headerText\":\"Area\",\"editType\":\"dropdown\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DocumentCategoryId\",\"headerText\":\"Document Category ID\",\"editType\":\"dropdown\",\"textAlign\":\"right\",\"visible\":false,\"width\":75,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"number\"},{\"field\":\"DocumentCategoryName\",\"headerText\":\"Category\",\"editType\":\"dropdown\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"DocumentStatusId\",\"headerText\":\"Document Status ID\",\"editType\":\"dropdown\",\"textAlign\":\"right\",\"visible\":false,\"width\":75,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"number\"},{\"field\":\"DocumentStatusName\",\"headerText\":\"Document Status\",\"editType\":\"dropdown\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"Extension\",\"headerText\":\"Ext\",\"allowEditing\":false,\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"textAlign\":\"left\",\"type\":\"string\"},{\"field\":\"NumberOfPages\",\"headerText\":\"Pages\",\"editType\":\"numeric\",\"textAlign\":\"right\",\"tooltip\":\"#colTip\",\"visible\":true,\"showInColumnChooser\":true,\"allowResizing\":true,\"type\":\"number\"}],\"isResponsive\":true,\"enableResponsiveRow\":false,\"virtualLoading\":null,\"keyConfigs\":{\"focus\":\"e\",\"insertRecord\":\"45\",\"deleteRecord\":\"46\",\"editRecord\":\"113\",\"saveRequest\":\"13\",\"cancelRequest\":\"27\",\"nextPage\":\"34\",\"previousPage\":\"33\",\"lastPage\":\"ctrl+alt+34\",\"firstPage\":\"ctrl+alt+33\",\"nextPager\":\"alt+34\",\"previousPager\":\"alt+33\",\"firstCellSelection\":\"36\",\"lastCellSelection\":\"35\",\"firstRowSelection\":\"ctrl+36\",\"lastRowSelection\":\"ctrl+35\",\"upArrow\":\"38\",\"downArrow\":\"40\",\"rightArrow\":\"39\",\"leftArrow\":\"37\",\"moveCellRight\":\"9\",\"moveCellLeft\":\"shift+9\",\"selectedGroupExpand\":\"alt+40\",\"totalGroupExpand\":\"ctrl+40\",\"selectedGroupCollapse\":\"alt+38\",\"totalGroupCollapse\":\"ctrl+38\",\"multiSelectionByUpArrow\":\"shift+38\",\"multiSelectionByDownArrow\":\"shift+40\"}}"

Object



searchResults



I think it could be a problem because of the custom columns. But, I'm not sure how can I debug this further or test my theory.

Could you give some help of what could be happening?

Kind regards,

Juan Acosta

 

16 Replies

JK Jayaprakash Kamaraj Syncfusion Team December 8, 2016 12:55 PM UTC

Hi Juan,  
 
Thanks for contacting Syncfusion support.  
 
We have created a sample and checked the issue by using the provided code snippets, but we were unable to reproduce the reported issue. Refer to the sample in following link.  
 
 
Please share the following information to find the cause of the issue. 
 
1.     Scenario to reproduce the issue.  
2.     Essential studio and browser version details.  
3.     Code example for loadDetailsGridFromCache(). 
3.     Share sample if possible or modify the attached sample as issue reproducible.  
  
Regards,  
 
Jayaprakash K. 



JA Juan Acosta December 9, 2016 07:42 AM UTC

Hi Jayaprakash,

1.     Scenario to reproduce the issue. 

* Load the screen with the current grid.
      * Then select a dropdownlist that will generate the event and call the controller.
      * The controller will return the new results list (storing the results list in cache).
      * the results list will repopulate the grid again.
      * the user will call the export buttons on click in the desired toolbar icon.

2.     Essential studio and browser version details. 

       Version=14.2450.0.26
       Browser
                Google Chrome Version 54.0.2840.99 m (64-bit)
                      FF 50.0.2

3.     Code example for loadDetailsGridFromCache().

        private void loadDetailGridFromCache()
        {
            if (HttpRuntime.Cache.Get("DocumentDetailsSearchFor" + ClaimsPrincipal.Current.FindFirst("dt_userid").Value) != null)
                this.searchDocumentsResults = (List<VDocumentShort>)HttpRuntime.Cache.Get("DocumentDetailsSearchFor" + ClaimsPrincipal.Current.FindFirst("dt_userid").Value);
        }


        The code simply recovered the results from cache to avoid another call to the backend.

4.     Share sample if possible or modify the attached sample as issue reproducible. 

         I will need to do something similar. I cannot pass the original code for the complexity of the backend calls required.

There is any way to activate more levels of debugging with the Syncfusion controls?

Kind regards,

Juan


JK Jayaprakash Kamaraj Syncfusion Team December 14, 2016 01:23 PM UTC

Hi Juan, 
 
The mentioned issue is occurred, due to when the columns bound to the Grid are not defined in the Grid dataSource. We have already discussed the same issue in following knowledge base document.  
 
 
For example if the column field name “Employee1” is not defined in Grid dataSource, the null exception will be thrown while exporting the Grid dataSource. So, please ensure the columns bound to the Grid are defined in the Grid dataSource before exporting the Grid 
 
Regards, 
 
Jayaprakash K. 



JA Juan Acosta December 14, 2016 11:12 PM UTC

Hi Jayaprakash,

I understand now the issue.  However, there is any way that I modified the model to avoid using the custom column IN/OUT and Options. Becuase, those columns are loaded dynamically from information received and are never bind directly to the gridDataSource. I need those columns for showing some specified values to the user. Generally speaking, it does not make sense to export them to any other format.

Could you help me to achieve that.

Kind regards,

Juan


JK Jayaprakash Kamaraj Syncfusion Team December 15, 2016 01:37 PM UTC

Hi Juan, 
 
To overcome this problem we suggest you to splice the grid dataSource property on ignoreOnExport method then handle the grid model dataSource in server side with Type Builder. Please refer to the below code example. 

@(Html.EJ().Grid<object>("FlatGrid") 
        .. 
 
       }).ClientSideEvents(eve=>eve.DataBound("databound"))) 
<script type="text/javascript"> 
    function databound(args) { 
        var grid = $('#FlatGrid').ejGrid('instance'); 
        grid.ignoreOnExport.splice(grid.ignoreOnExport.indexOf('dataSource'), 1); // here we will splice dataSource property in ignoreOnExport method 
    } 
 
</script> 
 
GridController.cs 
 
public ActionResult GridFeatures() 
        { 
            var DataSource = new NorthwindDataContext().OrdersViews.Take(50).ToList(); 
            ViewBag.datasource = DataSource; 
            return View(); 
        } 
        public void ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            JavaScriptSerializer serializer = new JavaScriptSerializer(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            Type tableType = GetTableType(obj); 
 
            // Create instance of Array to the dynamic table type 
            var inst = Array.CreateInstance(tableType, 1); 
      
 
            string griddata = serializer.Serialize(obj.DataSource); 
 
 
            // serialize the export data as object array 
 
            obj.DataSource = serializer.Deserialize(griddata, inst.GetType()) as object[]; 
 
 
            exp.Export(obj, (IEnumerable)(obj.DataSource), "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); 
        } 
        public static Type GetTableType(GridProperties gridProperty) 
        { 
            // Create needed TypeBuilder helpers 
            AppDomain myDomain = Thread.GetDomain(); 
            AssemblyName myAsmName = new AssemblyName("Anonymous"); 
            AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.Run); 
 
            ModuleBuilder myModBuilder = myAsmBuilder.DefineDynamicModule(myAsmName.Name); 
            TypeBuilder myTypeBuilder = myModBuilder.DefineType("TestClass", TypeAttributes.Public); 
 
            foreach (var col in gridProperty.Columns) 
            { 
                Type PropertyType; 
                var PropertyName = col.Field; 
 
                if (col.CustomAttributes.Count > 0) 
                { 
                    var colTypeAct = col.CustomAttributes["type"]; 
                    if (colTypeAct.Equals("duration")) 
                    { 
                        col.Type = "string"; 
                    } 
 
                } 
                if (col.HeaderText.Contains("<BR>")) 
                { 
                    col.HeaderText = col.HeaderText.Replace("<BR>", ""); 
 
                } 
                switch (col.Type) 
                { 
                    case "number": PropertyType = Type.GetType("System.Decimal"); 
                        break; 
 
                    case "string": PropertyType = Type.GetType("System.String"); 
                        break; 
                    case "boolean": PropertyType = Type.GetType("System.Boolean"); 
                        break; 
                    case "date": PropertyType = Type.GetType("System.DateTime"); 
                        break; 
                    default: PropertyType = Type.GetType("System.String"); 
                        break; 
                } 
 
                FieldBuilder PropertyFieldBuilder = myTypeBuilder.DefineField(PropertyName.ToLower(), PropertyType, FieldAttributes.Private); 
 
                PropertyBuilder PBuilder = myTypeBuilder.DefineProperty(PropertyName, System.Reflection.PropertyAttributes.HasDefault, PropertyType, null); 
 
                MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.HideBySig; 
 
                MethodBuilder getPropertyBuilder = myTypeBuilder.DefineMethod("get" + PropertyName, getSetAttr, PropertyType, Type.EmptyTypes); 
 
                // Constructing IL Code for get and set Methods. 
                ILGenerator GetPropGenerator = getPropertyBuilder.GetILGenerator(); 
 
                GetPropGenerator.Emit(OpCodes.Ldarg_0); 
                GetPropGenerator.Emit(OpCodes.Ldfld, PropertyFieldBuilder); 
                GetPropGenerator.Emit(OpCodes.Ret); 
 
                MethodBuilder setPropertyBuulder = myTypeBuilder.DefineMethod("set_" + PropertyName, getSetAttr, null, new Type[] { PropertyType }); 
 
                ILGenerator SetPropGenerator = setPropertyBuulder.GetILGenerator(); 
 
                SetPropGenerator.Emit(OpCodes.Ldarg_0); 
                SetPropGenerator.Emit(OpCodes.Ldarg_1); 
                SetPropGenerator.Emit(OpCodes.Stfld, PropertyFieldBuilder); 
                SetPropGenerator.Emit(OpCodes.Ret); 
 
                PBuilder.SetGetMethod(getPropertyBuilder); 
 
                PBuilder.SetSetMethod(setPropertyBuulder); 
            } 
 
            ConstructorInfo objCtor = typeof(object).GetConstructor(new Type[-1 + 1]); 
            ConstructorBuilder pointCtor = myTypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes); 
 
            ILGenerator ctorIL = pointCtor.GetILGenerator(); 
 
            // Constructing IL Code for the Type Constructor. 
            ctorIL.Emit(OpCodes.Ldarg_0); 
            ctorIL.Emit(OpCodes.Call, objCtor); 
            ctorIL.Emit(OpCodes.Ret); 
 
            return myTypeBuilder.CreateType(); 
        } 
        private static PropertyInfo[] GetProperties(object obj) 
        { 
            return obj.GetType().GetProperties(); 
        } 
 
        private GridProperties ConvertGridObject(string gridProperty) 
        { 
            JavaScriptSerializer serializer = new JavaScriptSerializer(); 
            IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable)); 
            GridProperties gridProp = new GridProperties(); 
            foreach (KeyValuePair<string, object> ds in div) 
            { 
      
                    var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase); 
                    if (property != null) 
                    { 
                        Type type = property.PropertyType; 
                        string serialize = serializer.Serialize(ds.Value); 
                        object value = serializer.Deserialize(serialize, type); 
                        property.SetValue(gridProp, value, null); 
                    } 
               
            } 
            return gridProp; 
        } 
 
Attached GridController.cs file. Please refer to the below link. 
 
  
Regards, 
 
Jayaprakash K. 
 



JA Juan Acosta December 19, 2016 03:36 AM UTC

Hi Jayaprakash,

Thank you so much for your help, I added the method and review the fields that give problems as null.



One last question, How can I remove the first two columns from the result?

Kind regards,

Juan


JK Jayaprakash Kamaraj Syncfusion Team December 20, 2016 01:12 PM UTC

Hi Juan, 
 
We suggest you to remove the first two columns in Grid model before exporting and then export the Grid with updated Grid model using export method. Please refer to the below code example. 

        public void ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            JavaScriptSerializer serializer = new JavaScriptSerializer(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            Type tableType = GetTableType(obj); 
 
            // Create instance of Array to the dynamic table type 
            var inst = Array.CreateInstance(tableType, 1); 
      
 
            string griddata = serializer.Serialize(obj.DataSource); 
 
 
            // serialize the export data as object array 
 
            obj.DataSource = serializer.Deserialize(griddata, inst.GetType()) as object[]; 
            for (int i = 0; i < 2; i++) 
            { 
                obj.Columns.RemoveAt(i); 
            } 
            exp.Export(obj, (IEnumerable)(obj.DataSource), "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); 
        } 

Regards, 
 
Jayaprakash K. 



JA Juan Acosta December 20, 2016 11:52 PM UTC

Hi Jayaprakash,

Thanks for your reply. That works perfectly. I have a question for you.

I also print the grid.

I found that I need to modify the printing options.



How is the printing working?

I found that The code does not have any mappers connected to the controller.

.ToolbarSettings(toolbar =>
                    {
                        toolbar.ShowToolbar().ToolbarItems(items =>
                        {
                            items.AddTool(ToolBarItems.PrintGrid);
                            items.AddTool(ToolBarItems.ExcelExport);
                            items.AddTool(ToolBarItems.WordExport);
                            items.AddTool(ToolBarItems.PdfExport);
                        });
                    })
                    .ToolbarSettings(toolbar =>
                    {
                        toolbar.ShowToolbar(true).CustomToolbarItems(new List<object>() {
                            "Notifications", "Download", "Maintenance", "Security"
                        });
                    })
                    .Mappers(map => map.ExportToExcelAction("/DocumentDetails/ExportToExcel").ExportToPdfAction("/DocumentDetails/ExportToPdf").ExportToWordAction("/DocumentDetails/ExportToWord"))
                    .AllowResizing(true)
Could you please explain to me, how can I do that with the printing option too.

Kind regards,

Juan





JA Juan Acosta December 21, 2016 12:17 AM UTC

Hi Jayaprakash,

I found one issue in the delete process.

Check this:

I have 18 columns initially:



I remove the first 5, so, I should be removed In/Out, Options, Versions, Name, Document. However, when I check again some of the columns are not removed.



It is any way that I can remove the columns based on their header name? Maybe that will fix the issue.

Kind regards,

Juan



JK Jayaprakash Kamaraj Syncfusion Team December 21, 2016 12:35 PM UTC

Hi Juan, 
 
Query 1: I found one issue in the delete process.  
 
We can able to exclude template column in excel sheet by passing the isTemplateColumnIclude parameter as false to the export method of the ExcelExport Class. We have faced the issue in version 14.2.0.26. It is a known issue and we have already fixed it and included in our latest version 14.4.0.15. So, please upgrade to the new version that can be downloaded from the following link, 
 
 
Please follow the below steps. 
 
1)     Download and install the Essential Studio v14.4.0.15 .  
 
2)     Replace the Syncfusion scripts, CSS and DLL’s in your project from the following location. 
 
            Scripts and CSS: C:\Program Files (x86)\Syncfusion\Essential Studio\XX.X.X.XX\JavaScript\assets 
            Dlls: C:\Program Files (x86)\Syncfusion\Essential Studio\ XX.X.X.XX \Assemblies 
 
Here XX.X.X.XX denotes the product version(14.4.0.15). 
 
And also after upgrading please ensure to clear the browser cache to avoid accidental reference of the old scripts/CSS. 
 
 Please refer to the below code example. 

public void ExportToExcel(string GridModel) 
        { 
            ExcelExport exp = new ExcelExport(); 
            JavaScriptSerializer serializer = new JavaScriptSerializer(); 
            GridProperties obj = ConvertGridObject(GridModel); 
.. 
            exp.Export(obj, (IEnumerable)(obj.DataSource), "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); //here, the 6th parameter is "isTemplateColumnIclude" which we have set as false.             
        } 

Query 2: How is the printing working? I found that The code does not have any mappers connected to the controller.  
 
As like exporting we cannot handle print feature in server side. Since it is a browser dependent feature, it is completely handled in client side only. Please refer to the below help document. 
 
 
Regards, 
 
Jayaprakash K. 



JA Juan Acosta February 9, 2017 08:47 AM UTC

Hi Jayaprakash,

Thanks for your reply. I upgrade to the version 14.4 and I stop getting the issues with excel.

I was checking the page that you send me about the printing properties. But it is not helping me at all.

I need to modify the grid before it is forwarded to the print function in the browser.


Grid Original



So, I can remove the fields that are mapped dynamically on the grid.

Could you please help me to achieve that. 

Kind regards,

Juan Acosta



JK Jayaprakash Kamaraj Syncfusion Team February 13, 2017 12:14 PM UTC

Hi Juan, 

We have achieved your requirement using ToolBarClick event of ejGrid. In this event we need the splice template columns in grid model and we need to call refreshContent method to refresh the grid and then we need to print the grid using ej.Print() when args.requestType as Print. Please refer to the below help document, code example and sample. 





@(Html.EJ().Grid<OrdersView>("Grid") 
                    .Datasource((IEnumerable<object>)ViewBag.datasource) 
 
                       .. 
 
                       }) 
 
                        .ClientSideEvents(eve => { eve.ToolbarClick("toolbarclick"); }) 
                        ) 
 
                        <script type="text/javascript"> 
                            function toolbarclick(args) { 
                                if (args.itemName == "Print") { 
                                    args.cancel = true; 
                                    var obj = $("#Grid").data("ejGrid"); 
                                    window.a = obj.model.columns; 
                                    window.b = $.extend(true, [], obj.model.columns); // here we have stored grid columns in window variable 
                                    for (i = 0; i < obj.model.columns.length; i++) { 
                                        if (!ej.isNullOrUndefined(obj.model.columns[i].template)) { 
                                            obj.model.columns.splice(i, 1); 
                                            i--; 
                                        } 
                                    } 
                                    obj.refreshContent(true); // refreshed the grid for remove template column 
                                    var ele = obj.element.clone(); 
                                    ej.print(ele); 
                                    obj.model.columns = window.b; 
                                    obj.columns(window.b); // here we have refreshed grid with template columns 
                                } 
                            } 
                        </script> 


Regards, 

Jayaprakash K. 



JA Juan Acosta February 14, 2017 05:18 AM UTC

Hi Jayaprakash,

I was trying to run the test project you update and I got this error.






Could you let me know what is the issue?

Kind regards,

Juan


JK Jayaprakash Kamaraj Syncfusion Team February 15, 2017 12:53 PM UTC

Hi Juan, 

We suspect that the mentioned issue occurs when the DLL’s version mismatch in webconfig and bin folder of the sample.  So, please clear bin and obj folder in that sample and also clear the browser cache. 

Regards, 

Jayaprakash K. 



JA Juan Acosta February 16, 2017 11:41 PM UTC

Hi Jayaprakash,

I tried to clean the bin folder and rebuild. However, I'm still getting the same error. Anyway, what I did was take the code that was managing the removal of the fields and added directly.

I found some issues:

The call

function toolbarclick(args) {
    if (args.itemName == "Print")


does not work properly for me
I changed for
 GridToolClick(sender) {
        $target = $(sender.target);
        if ($target.hasClass("e-print e-toolbaricons e-icon")) {


However, the code that is removing the fields is not doing anything.



I tried even to remove the columns manually, like in the line 1888. Without any success.



I have a question about your code, the call 
var obj = $("#Grid").data("ejGrid");

ejGrid is just a name? Because, it is not defined in any part of the code.

Could you explain to me, how can I force the removal of columns explicitly?

Kind regards,

Juan



JK Jayaprakash Kamaraj Syncfusion Team February 17, 2017 12:30 PM UTC

Hi Juan, 

A support incident has been created under your account to resolve the issue. Please log on to our support website to check for further updates.  
 
Regards,                                                                                                                                     
Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon