I have an programmatically built Ajaxified RadGrid that is being built when the RadToolTipManager is called and TheRadToolTipManager_AjaxUpdate event is triggered. The tool tip and grid works and shows all the data I am looking for, and I would like to be able to export the data. I am using the built-in export button that the RadGrid has available, but when I click the export button it disappears and no export file is created. I have read the Export from Ajaxified Grid page and understand that the built-in button already performs the post backs, so I am stuck.
Programmatically built RadGrid:
private void UpdateToolTip(string elementID, UpdatePanel panel){ RadGrid toolTipGrid= new RadGrid(); toolTipGrid.ID = "ToolTipGridID"; toolTipGrid.AutoGenerateColumns = false; toolTipGrid.EnableViewState = false; toolTipGrid.MasterTableView.ExpandCollapseColumn.Visible = false; GridBoundColumn boundColumn = new GridBoundColumn(); boundColumn.DataField = "Data1"; boundColumn.HeaderText = "Data1"; boundColumn.DataType = typeof(string); boundColumn.UniqueName = "Data1"; boundColumn.Exportable = true; toolTipGrid.MasterTableView.Columns.Add(boundColumn); boundColumn = new GridBoundColumn(); boundColumn.DataField = "Data2"; boundColumn.HeaderText = "Data2"; boundColumn.DataType = typeof(int); boundColumn.UniqueName = "Data2"; boundColumn.Exportable = true; toolTipGrid.MasterTableView.Columns.Add(boundColumn); // Export stuff toolTipGrid.MasterTableView.CommandItemSettings.ShowExportToExcelButton = true; toolTipGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false; toolTipGrid.MasterTableView.CommandItemSettings.ShowRefreshButton = false; toolTipGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Bottom; toolTipGrid.ItemCommand += toolTipGrid_ItemCommand; toolTipGrid.AllowPaging = true; toolTipGrid.PageSize = 20; toolTipGrid.PagerStyle.Mode = GridPagerMode.NextPrev; toolTipGrid.NeedDataSource += CargoMileageInfo_NeedDataSource; toolTipGrid.DataSource = DataForToolTip; toolTipGrid.DataBind(); panel.ContentTemplateContainer.Controls.Add(toolTipGrid); }
The button triggers the toolTipGrid_ItemCommand
private void toolTipGrid_ItemCommand(object sender, GridCommandEventArgs e){ RadGrid toolTipGrid= (RadGrid)sender; if (e.CommandName == RadGrid.ExportToExcelCommandName) { toolTipGrid.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx; toolTipGrid.ExportSettings.IgnorePaging = true; toolTipGrid.ExportSettings.ExportOnlyData = true; toolTipGrid.ExportSettings.OpenInNewWindow = true; }}
Advance DataBind:
private void toolTipGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e){ RadGrid toolTipGrid= (RadGrid)sender; toolTipGrid.DataSource = DataForToolTip;}
This may be related, but I have debugged and stepped through my code to see where it breaks when the button is clicked, and I get this error, "JavaScript runtime error: Unable to get property 'Cols' of undefined or null reference occurred."
