Hi I am using radgrid and I want to apply export excel functionality on that but when I am trying to add header using Prerender event it is not working for
rgEnrolmentExport.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
I need this format to remove prompt which we normally get on opening of Xls file
So please see code
On aspx -
<telerik:RadGrid ID="rgEnrolmentExport" OnPreRender="rgEnrolmentExport_PreRender" runat="server" AllowPaging="false" AutoGenerateColumns="true" ExportSettings-Excel-Format="Html">
<ExportSettings IgnorePaging="True" OpenInNewWindow="True" ExportOnlyData="True">
</ExportSettings>
</telerik:RadGrid>
on C#
rgEnrolmentExport.DataSource = dtExportData;
rgEnrolmentExport.DataBind();
DateTime obj1 = (DateTime)rdpExportDate.SelectedDate;
rgEnrolmentExport.ExportSettings.FileName = "HO_Enrollment_Source_Report_" + obj1.ToString("MM.yyyy");
rgEnrolmentExport.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
// rgEnrolmentExport.ExportSettings.Excel.FileExtension = "Xlsx";
rgEnrolmentExport.HeaderStyle.Font.Bold = true;
rgEnrolmentExport.MasterTableView.ExportToExcel();
And in Prerender
protected void rgEnrolmentExport_PreRender(object sender, EventArgs e)
{
//get the current header
GridItem[] header = rgEnrolmentExport.MasterTableView.GetItems(GridItemType.Header);
if (header.Length > 0)
{
//get the current THead element
DateTime obj1 = (DateTime)rdpExportDate.SelectedDate;
GridTHead head = ((GridTHead)header[0].Parent.Controls[0].Parent);
//Get the GridHeaderItem from the THead
GridHeaderItem currentHeaderItem = (GridHeaderItem)head.Controls[0];
//Clear all GridHeaderItems
head.Controls.Clear();
//create a new GridHeaderItem which will be the new row
GridHeaderItem newHeaderItem = new GridHeaderItem(rgEnrolmentExport.MasterTableView, 0, 0);
// newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells.Add(new GridTableHeaderCell { Text = "Massachusetts", ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
newHeaderItem.Cells.Add(new GridTableHeaderCell { Text = "Rhode Island", ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
// newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells.Add(new GridTableHeaderCell { Text = "New Hampshire", ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
// newHeaderItem.Cells.Add(new GridTableHeaderCell());
newHeaderItem.Cells.Add(new GridTableHeaderCell { Text = "All EMembers", ColumnSpan = 3, HorizontalAlign = HorizontalAlign.Center });
// head.Controls.AddAt(0, newHeaderItem);
GridHeaderItem newHeaderItem1 = new GridHeaderItem(rgEnrolmentExport.MasterTableView, 0, 0);
newHeaderItem1.Cells.Add(new GridTableHeaderCell());
newHeaderItem1.Cells.Add(new GridTableHeaderCell());
newHeaderItem1.Cells.Add(new GridTableHeaderCell { Text = "Heating Oil Enrollment Sources Report for " + obj1.ToString("MMMMM yyyy"), ColumnSpan = 12, HorizontalAlign = HorizontalAlign.Center });
//Add back the GridHeaderItems in the order you want them to appear
head.Controls.Add(newHeaderItem1);
head.Controls.Add(newHeaderItem);
head.Controls.Add(currentHeaderItem);
}
}
So basically if I am not applying Xlsx format it woking fine pelase see attachment it is exoporting what ever I need to do but with Xlsx format it throwing error.
So conclusion is I need to export file as I have attached in Image but in Xlsx format
Hello,
I have implemented RadGid with filter options. I have 2 quries:
1. How to show default text e.g "Search..." for filters for some of the columns(not All columns).
2. When user clicks on Filter Textbox it should populate all the values for that column.
Hello,
I am new to this forum and using Telerik controls for the first time.
I am using RadGid in Provider Hosted Add-In and so far could bind the data to it. My questions are:
1. When i use default ExportToExcel functionality nothing happens.. The page becomes blank after showing RadAjaxLoadingPanel
I have written below code for that:
protected void RadGrid_ItemCommand(object source, GridCommandEventArgs e)
{
if (e.CommandName == RadGrid.ExportToExcelCommandName)
{
RadGridRequests.ExportSettings.Excel.Format = GridExcelExportFormat.Biff;
RadGridRequests.ExportSettings.IgnorePaging = true;
RadGridRequests.ExportSettings.ExportOnlyData = true;
RadGridRequests.ExportSettings.OpenInNewWindow = true;
}
}
I'm using RadGrid to export to Excel. Everything works except the worksheets have an extra tab named 'License' that contains the following text: "This document was generated by a trial version of Telerik Document Processing.".
I would like to suppress the creation of this tab. The online demo here does not create this tab: http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/exporting/excel-export/defaultcs.aspx?show-source=true
Has anyone encountered and addressed this?
Thanks.
I'm in the process of updating to use the newest version of UI for ASP.NET AJAX. We were using Q2 2014.
One of our pages had a RadGrid with 12 visible columns. After upgrading to 2017_9_913 3 of the columns no longer display. The only update we made to the .aspx file was to reference the new Telerik DLL.
See attached images showing screen shot and code.
Hi,
I need to find a way to get the Command Item "Save Changes" Onclick event on the server side. So far i can only capture the event on the ItemCommand event but there is no way of discerning when it comes from the Save changes button.
The long story:
I have a grid that populates with a read only view. I added a template column with a ComboBox. Based on the selection of that ComboBox I will issue an insert command to a separate table.
I was hoping that the built in functionality of the command items would let me override the Save Changes event so I can iterate through all the RadGrid.SelectedItems and do my inserts.
I know I can do this using a custom button, but i really hoped there would be some built in functionality for this.
Is there a way of capturing or overriding that event?
Is it possible to have a hierarhical virtualized RadGrid (with detailtable) ?
The main grid is virtualized, the child grid is populated in the DetailTableDataBind event.
I'm asking because I've tried to add virtualization on the demo code (http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/programmatic-hierarchy/defaultcs.aspx) and on expanding certain rows the client start sending non stop getData calls to the server and retrieves parent datasource over and over again.
<
telerik:RadGrid
ID
=
"myRadGrid"
runat
=
"server"
Width
=
"75%"
BorderWidth
=
"1px"
CellPadding
=
"6"
GridLines
=
"None"
BorderColor
=
"#404040"
Skin
=
"Web20"
>
<
ExportSettings
ExportOnlyData
=
"true"
FileName
=
"DonorSlots"
IgnorePaging
=
"true"
OpenInNewWindow
=
"true"
></
ExportSettings
>
<
MasterTableView
AutoGenerateColumns
=
"false"
DataKeyNames
=
"intDeployId"
Name
=
"MasterGrid"
BorderColor
=
"#404040"
Font-Size
=
"9"
Font-Names
=
"Veranda,arial,sans-serif"
AllowPaging
=
"True"
PageSize
=
"20"
PagerStyle-Mode
=
"NumericPages"
HeaderStyle-HorizontalAlign
=
"Center"
GridLines
=
"Both"
BorderWidth
=
"1px"
CommandItemDisplay
=
"Top"
EditMode
=
"EditForms"
>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"false"
ShowExportToExcelButton
=
"false"
/><
AlternatingItemStyle
BackColor
=
"#B0C4DE"
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/><
HeaderStyle
ForeColor
=
"White"
Font-Bold
=
"true"
BorderColor
=
"#404040"
BorderWidth
=
"1px"
/>
<
CommandItemTemplate
>
<
table
width
=
"100%"
>
<
tr
>
<
td
align
=
"right"
><
asp:Button
ID
=
"btnExport"
runat
=
"server"
CommandName
=
"ExportToExcel"
Text
=
"Export Excel"
/></
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
EditText
=
"Update"
></
telerik:GridEditCommandColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"HIST"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"imgLooker"
runat
=
"server"
ImageUrl
=
"~/Images/ViewResources.gif"
ImageAlign
=
"Middle"
BorderStyle
=
"None"
/>
<
asp:PopupControlExtender
ID
=
"popInfo"
runat
=
"server"
PopupControlID
=
"pnlPop"
TargetControlID
=
"imgLooker"
DynamicContextKey='<% #Eval("strSSN") %>'
DynamicControlID="pnlpop" DynamicServiceMethod="HelloWorld" Position="bottom"></
asp:PopupControlExtender
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"strFullname"
HeaderText
=
"NAME"
/>
<
telerik:GridBoundColumn
DataField
=
"strPrevUic"
HeaderText
=
"PRIOR UIC"
/>
<
telerik:GridBoundColumn
DataField
=
"strPara"
HeaderText
=
"PARA"
/>
<
telerik:GridBoundColumn
DataField
=
"strLine"
HeaderText
=
"LINE"
/>
<
telerik:GridBoundColumn
DataField
=
"strGrade"
HeaderText
=
"GRADE"
/>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
width
=
"100%"
>
<
tr
>
<
td
style
=
"width:50%"
align
=
"right"
>Prior Uic: </
td
>
<
td
style
=
"width:50%"
align
=
"left"
><
asp:TextBox
ID
=
"txtPriorUic"
runat
=
"server"
Width
=
"100px"
Text='<%# Bind("strPrevUic") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:5px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:50%"
align
=
"right"
>Para: </
td
>
<
td
style
=
"width:50%"
align
=
"left"
"><
asp:TextBox
ID
=
"txtpara"
runat
=
"server"
Width
=
"100px"
Text='<%# Bind("strPara") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:5px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:50%"
align
=
"right"
> Line: </
td
>
<
td
style
=
"width:50%"
align
=
"left"
><
asp:TextBox
ID
=
"txtLine"
runat
=
"server"
Width
=
"100px"
Text='<%# Bind("strLine") %>'></
asp:TextBox
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"height:5px"
></
td
>
</
tr
>
<
tr
>
<
td
style
=
"width:50%"
align
=
"right"
>Return Grade: </
td
>
<
td
style
=
"width:50%"
align
=
"left"
><
asp:DropDownList
ID
=
"ddlRank"
runat
=
"server"
CausesValidation
=
"false"
Width
=
"105px"
>
<
asp:ListItem
Value
=
"0"
>Pick Grade</
asp:ListItem
>
<
asp:ListItem
Value
=
"E4"
>E4 Below</
asp:ListItem
>
<
asp:ListItem
Value
=
"E5"
>E5</
asp:ListItem
>
<
asp:ListItem
Value
=
"E6"
>E6</
asp:ListItem
>
<
asp:ListItem
Value
=
"E7"
>E7</
asp:ListItem
>
<
asp:ListItem
Value
=
"E8"
>E8</
asp:ListItem
>
<
asp:ListItem
Value
=
"E9"
>E9</
asp:ListItem
>
<
asp:ListItem
Value
=
"W1"
>W1</
asp:ListItem
>
<
asp:ListItem
Value
=
"W2"
>W2</
asp:ListItem
>
<
asp:ListItem
Value
=
"W3"
>W3</
asp:ListItem
>
<
asp:ListItem
Value
=
"W4"
>W4</
asp:ListItem
>
<
asp:ListItem
Value
=
"W5"
>W5</
asp:ListItem
>
<
asp:ListItem
Value
=
"O2"
>O2 Below</
asp:ListItem
>
<
asp:ListItem
Value
=
"O3"
>O3</
asp:ListItem
>
<
asp:ListItem
Value
=
"O4"
>O4</
asp:ListItem
>
<
asp:ListItem
Value
=
"O5"
>O5</
asp:ListItem
>
<
asp:ListItem
Value
=
"O6"
>06</
asp:ListItem
>
<
asp:ListItem
Value
=
"O7"
>O7</
asp:ListItem
>
<
asp:ListItem
Value
=
"O8"
>08</
asp:ListItem
>
</
asp:DropDownList
>
</
td
>
</
tr
>
</
table
>
<
table
width
=
"100%"
>
<
tr
>
<
td
style
=
"width:50%"
align
=
"right"
></
td
>
<
td
style
=
"width:50%"
align
=
"left"
>
<
asp:LinkButton
ID
=
"lnkSubmit"
runat
=
"server"
text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>'></
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkCancel"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"Cancel"
Text
=
"Cancel"
></
asp:LinkButton
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
Protected Sub myRadGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myRadGrid.NeedDataSource
Dim DeployId As String = Convert.ToInt16(ddlDeployment.SelectedValue.ToString())
Dim Bn As String = ddlBn.SelectedValue
Dim Uic As String = ddlUic.SelectedValue
Dim SqlWhere As String = ""
If CInt(DeployId) > 0 And Bn = "0" And ddlUic.SelectedValue = "" Then
SqlWhere = "mu.intMobilizationId = " & ddlDeployment.SelectedValue & " "
ElseIf CInt(DeployId) > 0 And ddlBn.SelectedValue > "" And ddlUic.SelectedValue = "0" Then
SqlWhere = "mu.intMobilizationId = " & ddlDeployment.SelectedValue & " and mu.strAAUic = '" & ddlBn.SelectedValue & "'"
ElseIf CInt(DeployId) > 0 And ddlBn.SelectedValue > "0" And ddlUic.SelectedValue > "0" Then
SqlWhere = "mu.intMobilizationId = " & ddlDeployment.SelectedValue & " and mu.strAAUic = '" & ddlBn.SelectedValue & "' and mu.intUnitMobId = " & ddlUic.SelectedValue & ""
End If
sql = "Select up.intDeployId, up.strPrevUic, up.strPara, up.strLine, up.strGrade, mn.strFullname, up.strSSN From tblMobUnitPersonnel as up INNER JOIN tblMobUnitPosition as p on p.intPositionID = up.intPositionId " _
& "INNER JOIN tblMOBUnits mu on mu.intUnitMobId = p.intUnitMobID INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel mn on mn.strSSN = up.strSSN WHERE " & SqlWhere & " Order by up.strPrevUic, up.strPara, up.strLine"
myRadGrid.DataSource = getData(sql)
End Sub