Monday, July 29, 2013

How to remove Checkbox/ columns from Telerik Grid when Export to Excel/pdf

Sometimes we are facing issues to remove certain column from Telerik Grid when export to Excel or PDF Or DOC. In that case use below to hide the column

protected void TelGrid_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.ExportToExcelCommandName || e.CommandName == RadGrid.ExportToCsvCommandName || e.CommandName == RadGrid.ExportToPdfCommandName) { TelGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None; TelGrid.MasterTableView.GetColumn("colChk").Display = false; TelGrid.MasterTableView.GetColumn("colDetails").Display = false; } } Here colChk and ColDetails is the column name in RadGrid.