This seemed easy but I'm having trouble changing the HeaderText of a column inside of the OnExportCellFormatting event when exporting my grid to Excel.
As an example I have a column with a headerText value of "11/2013</br>Actual" and I want to change change the </br> to a newline or CR "/r/n" ? Whatever will make the header wrap and have "11/2013" above "Actual". Which is how it is displayed in the Grid.
In my tests setting the headerText inside of the OnExportCellFormatting as below does not work.
e.FormattedColumn.HeaderText = "New Header Text";
The image is a little Add png icon (from examples) and it blows it up. I can't find anywhere to make it the normal size (or force a size). ItemStyle-width or height, HeaderStyle-width or height, or what's below don't have any affect on it. See screenshot.
<MasterTableView DataMember="Devices" DataKeyNames="ArticleID" headerStyle-Font-Bold="true" AllowFilteringByColumn="true" PageSize="20" >
<Columns>
<telerik:GridButtonColumn
CommandName="InitInsert"
Text="Add a Claim for this Device"
UniqueName="AddNewClaim"
ButtonType="imageButton"
ImageUrl="../../resources/Images/AddRecord.png"> <HeaderStyle Width="1px" /><ItemStyle Width="1px" /> </telerik:GridButtonColumn>
<telerik:GridBoundColumn
SortExpression="SerialNumber"
HeaderText="Serial Number"
HeaderButtonType="TextButton"
DataField="SerialNumber"
UniqueName="SerialNumber"
HeaderStyle-Width="400"
FilterControlWidth="100"
CurrentFilterFunction="EqualTo"
AutoPostBackOnFilter="True"
AllowFiltering="True" />
<telerik:GridBoundColumn SortExpression="ArticleID" HeaderText="Article ID" HeaderButtonType="TextButton"
DataField="ArticleID" UniqueName="ArticleID" HeaderStyle-Width="800" FilterControlWidth="800" Visible="false" />
</Columns>

Hello,
I have a problem with Radcombox that is inside form template, I need that the first radcombo
This is the code aspx
<telerik:RadGrid runat="server" Id="rgDirecciones" AutoGenerateColumns="False" OnDeleteCommand="rgDirecciones_DeleteCommand" OnInsertCommand="rgDirecciones_InsertCommand" OnItemDataBound="rgDirecciones_ItemDataBound" OnUpdateCommand="rgDirecciones_UpdateCommand" CellSpacing="-1" GroupPanelPosition="Top" > <mastertableview datakeynames="IdDireccion,IdSucursal,IdEmpresa"> <rowindicatorcolumn visible="False"> </rowindicatorcolumn> <expandcollapsecolumn created="True"> </expandcollapsecolumn> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" EditImageUrl="../imagenes/Edit.png" InsertImageUrl="../imagenes/Edit.png" Exportable="False"> <HeaderStyle Width="30px" /> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="IdDireccion" UniqueName="IdDireccion" HeaderText="No Dirección"> <HeaderStyle Width="80px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="TipoDireccion" UniqueName="TipoDireccion" HeaderText="Tipo"> <HeaderStyle Width="80px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Direccion" UniqueName="Direccion" HeaderText="Dirección"> <HeaderStyle Width="200px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Referencia" UniqueName="Referencia" HeaderText="Referencia"> <HeaderStyle Width="200px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Organizacion" UniqueName="Organizacion" HeaderText="Organización"> <HeaderStyle Width="200px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="NombreContacto" UniqueName="NombreContacto" HeaderText="Nombre de Contacto"> <HeaderStyle Width="200px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="CodigoPostal" UniqueName="CodigoPostal" HeaderText="Código Postal"> <HeaderStyle Width="130px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="RowVersion" UniqueName="RowVersion" Display="False"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="IdSucursal" UniqueName="IdSucursal" HeaderText="Sucursal" Display="False"> <HeaderStyle Width="150px" /> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Pais" UniqueName="Pais" Display="False"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="DivisionTerritorial" UniqueName="DivisionTerritorial" Display="False"> </telerik:GridBoundColumn> <telerik:GridButtonColumn ConfirmText="Desea eliminar este registro?" ConfirmDialogType="RadWindow" ConfirmTitle="Eliminar" ButtonType="ImageButton" CommandName="Delete" ImageUrl="../imagenes/Delete.png" UniqueName="DeleteColumn" Text="Eliminar" FilterControlAltText="Filter DeleteColumn column" Exportable="False"> <HeaderStyle Width="30px" /> </telerik:GridButtonColumn> </Columns> <editformsettings editformtype="Template"> <editcolumn filtercontrolalttext="Filter EditCommandColumn1 column" uniquename="EditCommandColumn1"> </editcolumn> <formtemplate> <table class="table table-condensed"> <tr> <td style="width: 150px"> <asp:Label ID="lbIdDireccion" runat="server" Text="No Dirección"></asp:Label> </td> <td> <telerik:RadNumericTextBox ID="txtIdDireccion" runat="server" Enabled="<%# (Container is GridEditFormInsertItem) ? true : false %>" MaxLength="2" MaxValue="99" MinValue="0" Text='<%# Bind("IdDireccion") %>' Width="80px"> <numberformat decimaldigits="0" groupseparator="" /> </telerik:RadNumericTextBox> <asp:RequiredFieldValidator ID="rfvIdDireccion" runat="server" ControlToValidate="txtIdDireccion" Display="Dynamic" ErrorMessage="Campo Obligatorio" ForeColor="Red"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbPaisDire" runat="server" Text="PaÃs"></asp:Label> </td> <td> <telerik:RadComboBox ID="cmbPais" Runat="server" Width="350px" Height="150px" AutoPostBack="True" OnSelectedIndexChanged="combo_SelectedIndexChanged"> </telerik:RadComboBox> <asp:RequiredFieldValidator ID="rfvcmbPais" runat="server" Display="Dynamic" ForeColor="Red" ControlToValidate="cmbPais" ErrorMessage="Campo Obligatorio"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbDivisionTerritorial" runat="server" Text="División Territorial"></asp:Label> </td> <td> <telerik:RadComboBox ID="cmbDivisionTerritorial" Runat="server" Width="350px"> </telerik:RadComboBox> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbDireccion" runat="server" Text="Direccion"></asp:Label> </td> <td> <telerik:RadTextBox ID="txtDireccion" Runat="server" MaxLength="200" Text='<%# Bind("Direccion") %>' TextMode="MultiLine" Width="350px"> <ClientEvents OnValueChanging="removerMasDeUnEspacio" /> </telerik:RadTextBox> <asp:RequiredFieldValidator ID="rfvtxtDireccion" runat="server" Display="Dynamic" ForeColor="Red" ControlToValidate="txtDireccion" ErrorMessage="Campo Obligatorio"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbNombreContacto" runat="server" Text="NombreContacto"></asp:Label> </td> <td> <telerik:RadTextBox ID="txtNombreContacto" Runat="server" Text='<%# Bind("NombreContacto") %>' MaxLength="100" Width="350px"> <ClientEvents OnValueChanging="removerMasDeUnEspacio" /> </telerik:RadTextBox> <asp:RequiredFieldValidator ID="rfvtxtNombreContacto" runat="server" Display="Dynamic" ForeColor="Red" ControlToValidate="txtNombreContacto" ErrorMessage="Campo Obligatorio"> </asp:RequiredFieldValidator> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbOrganizacion" runat="server" CssClass="opcionales" Text="Organización"></asp:Label> </td> <td> <telerik:RadTextBox ID="txtOrganizacion" Runat="server" Text='<%# Bind("Organizacion") %>' MaxLength="100" Width="350px"> <ClientEvents OnValueChanging="removerMasDeUnEspacio" /> </telerik:RadTextBox> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbReferencia" runat="server" CssClass="opcionales" Text="Referencia"></asp:Label> </td> <td> <telerik:RadTextBox ID="txtReferencia" Runat="server" Text='<%# Bind("Referencia") %>' MaxLength="100" Width="350px"> <ClientEvents OnValueChanging="removerMasDeUnEspacio" /> </telerik:RadTextBox> </td> </tr> <tr> <td style="width: 150px"> <asp:Label ID="lbCodigoPostal" runat="server" CssClass="opcionales" Text="CodigoPostal"></asp:Label> </td> <td> <telerik:RadTextBox ID="txtCodigoPostal" Runat="server" Text='<%# Bind("CodigoPostal") %>' MaxLength="10" Width="80px"> <ClientEvents OnValueChanging="removerMasDeUnEspacio" /> </telerik:RadTextBox> </td> </tr> <tr> <td colspan="2"> <telerik:RadButton ID="RadButton1" runat="server" causesvalidation="true" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' Text='<%# (Container is GridEditFormInsertItem) ? "Agregar" : "Guardar" %>' validationgroup="Textbox"> <icon primaryiconurl="../imagenes/save_16x16.png" /> </telerik:RadButton> <telerik:RadButton ID="RadButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancelar"> <icon primaryiconurl="../imagenes/cancel.png" /> </telerik:RadButton> <asp:Label ID="Label2" runat="server" CssClass="opcionales" Text="* Opcionales"></asp:Label> </td> </tr> </table> </formtemplate> </EditFormSettings> <CommandItemTemplate> <div class="col-xs-6"> <asp:LinkButton ID="lbAgregarDirecciones" runat="server" CommandName="InitInsert" Visible='<%# !rgDirecciones.MasterTableView.IsItemInserted %>'><img style="border:2px;vertical-align:middle;" alt="" src="../imagenes/AddRecord.png"/> Agregar</asp:LinkButton> <asp:LinkButton ID="lbRefrescarDirecciones" runat="server"> <img style="border:2px;vertical-align:middle;" alt="" src="../imagenes/Refresh.png"/> Refrescar </asp:LinkButton> </div> <uc1:opcionesimportaciongrid runat="server" id="OpcionesImportacionGrid3" Grid="rgDirecciones" WebForm='<%# Page.Request.RawUrl.Substring(Page.Request.RawUrl.LastIndexOf("/") + 1) %>' NombreArchivo="Direcciones"/> </CommandItemTemplate> </mastertableview> </telerik:RadGrid>Code
protected void rgDirecciones_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditFormItem && e.Item.IsInEditMode)//editform { GridEditableItem item = (GridEditableItem)e.Item; GridEditFormItem editItem = (GridEditFormItem)e.Item; if (!(e.Item is IGridInsertItem)) { RadComboBox comboTipoDirecciones = (RadComboBox)editItem.FindControl("cmbTipoDireccion"); comboTipoDirecciones.SelectedValue = editItem["TipoDireccion"].Text; RadComboBox comboPais = (RadComboBox)editItem.FindControl("cmbPais"); comboPais.SelectedValue = editItem["Pais"].Text; } } }protected void combo_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { GridEditableItem editedItem = (sender as RadComboBox).NamingContainer as GridEditableItem; GridEditFormItem item = (sender as RadComboBox).NamingContainer as GridEditFormItem; RadComboBox comboPaises = sender as RadComboBox; RadComboBox comboDivisionTerritorial = (RadComboBox)editedItem.FindControl("cmbDivisionTerritorial"); var parametrosSQL = new string[] { null, e.Value }; DataSet ds = Clases.MetodosGlobales.ObtenerInformacionObjeto("ADMMDivisionesTerritoriales_get", parametrosSQL); comboDivisionTerritorial.Text = null; comboDivisionTerritorial.EmptyMessage = "- Seleccione un valor -"; comboDivisionTerritorial.Filter = RadComboBoxFilter.StartsWith; comboDivisionTerritorial.DataSource = ds.Tables[0]; comboDivisionTerritorial.DataTextField = "Descripcion"; comboDivisionTerritorial.DataValueField = "Divisionterritorial"; comboDivisionTerritorial.DataBind(); }The problem is that when I choose value of first radcombo. I fill the second radcombo but all the page load again and I lost the value of first combo and the second combo does not show the information. All the form is blank as if I did nothing
I do not understand what is the problem.
Regards,

hi dear,
i want to thank you about this work :) because it is very well.
kindly your support to provide me with an example that print radgrid into html pages and keep the header of grid because i want this html page specific design such as this page should have an image before i put radgid elements then put some radgrid elements then put again image and repeate it again for all items in radgrid.
also i want to ask you if i have radgrid with paging, can i get elements from each page seperately.
can you support me with example of code for both two above problemsvery quickly.
Thank you a lot.

I have some Numeric Textboxes where I am using the OnValueChanging client event to do some validation and when I utilize the eventArgs.set_cancel(true) function, the value is reverted back to the old value, however the currency format is lost when I exit the field. If I reenter the field and exit again, the dollar sign will display properly.
Here is a sample of the script:
function onValueChanging(sender, eventArgs) { var value = eventArgs.get_newValue(); var txtTest = $find("<%= txtTest.ClientID %>"); if ((value < sender.get_minValue()) || (value > txtTest.get_value())) { alert('Value must be a non-negative number and cannot exceed txtTest'); eventArgs.set_cancel(true); }}
Hi,
We have a radgrid.We have a requirement like entering the time and finding the sum of all the cells and display into the last column of the grid when columns are generating dynamically.
We have tried with client side event on row selected event but sum is not coming when moving from one cell to second cell.
Below i am giving the scenarios how we have used the client events please reply to this thread as early as possible.
1. We are
able to fetch the selected cell value but unable to fetch the remaining
corresponding cell values. You can find the same in the sample project
(BatchEdit.aspx – OnBatchEditCellValueChanged event)
source code:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function BatchEditCellValueChanged(sender, args) {
var grid = sender;
var row = args.get_row();
var cell = args.get_cell();
var tableView = args.get_tableView();
var column = args.get_column();
var columnUniqueName = args.get_columnUniqueName();
var editorValue = args.get_editorValue();
var cellValue = args.get_cellValue();
alert(editorValue);
var columnlength = grid.get_masterTableView().get_columns().length;
for (i = 0 ; i < columnlength; i++) {
cell = grid.get_masterTableView().get_columns()[i].get_uniqueName();
alert(cell);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<div>
<telerik:RadGrid ID="RadGrid1" runat="server">
<MasterTableView EditMode="Batch" BatchEditingSettings-EditType="Cell">
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" CellSelectionMode="MultiCell" />
<ClientEvents OnBatchEditCellValueChanged="BatchEditCellValueChanged" />
</ClientSettings>
</telerik:RadGrid>
</div>
</form>
</body>
</html>
code Behind:
public partial class BatchEdit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetValues();
}
private void GetValues()
{
DataTable dtTable = new DataTable();
dtTable.Columns.Add("Sum");
dtTable.Columns.Add("Value1"); dtTable.Columns.Add("Value2");
dtTable.Columns.Add("Value3"); dtTable.Columns.Add("Value4");
DataRow dr = dtTable.NewRow();
dr["Sum"] = "";
dr["Value1"] = "1"; dr["Value2"] = "2";
dr["Value3"] = "3"; dr["Value4"] = "4";
dtTable.Rows.Add(dr);
DataRow drr = dtTable.NewRow();
drr["Sum"] = "";
drr["Value1"] = "5"; drr["Value2"] = "6";
drr["Value3"] = "7"; drr["Value4"] = "8";
dtTable.Rows.Add(drr);
RadGrid1.DataSource = dtTable;
RadGrid1.DataBind();
}
}
2. We are
able to fetch the selected cell value and corresponding cell values in the same
row by hardcoding the column names, but dynamically we are unable to get the
values of the cell. You can find the same in the sample project
(OnRowSelected.aspx – OnRowSelected event)
source code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OnRowSelected.aspx.cs" Inherits="OnRowSelected" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
function RowSelected(sender, eventArgs) {
var grid = sender;
var MasterTable = grid.get_masterTableView();
var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
var cell1 = MasterTable.getCellByColumnUniqueName(row, "Value1");
var cell2 = MasterTable.getCellByColumnUniqueName(row, "Value2");
var cell3 = MasterTable.getCellByColumnUniqueName(row, "Value3");
var cell4 = MasterTable.getCellByColumnUniqueName(row, "Value4");
var total = 0;
var arr = [];
var total = 0;
var columnlength = grid.get_masterTableView().get_columns().length;
for (i = 0 ; i < columnlength; i++) {
cell = grid.get_masterTableView().get_columns()[i].get_uniqueName();
var cell = MasterTable.getCellByColumnUniqueName(row, cell);
var val = parseInt(cell.innerText);
arr[i] = val;
}
for (i = 1; i < arr.length; i++) {
total += arr[i];
}
var cell1 = MasterTable.getCellByColumnUniqueName(row, "Sum");
cell1.innerText = total;
cell1.eventArgs.set_cancel(true);
}
</script>
<%-- var grid = $find("<%=RadGrid1.ClientID%>");
var tableView = sender.get_masterTableView();
var batchManager = sender.get_batchEditingManager();
var items = tableView.get_dataItems();
var mapValues = [];
for (var i = 0; i < items.length; i++) {
var mapCell = items[i].get_cell("Map");
var mapValue = batchManager.getCellValue(mapCell);
mapValues.push(mapValue);
}--%>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<asp:HiddenField ID="HiddenField1" runat="server" />
<div>
<telerik:RadGrid ID="RadGrid1" runat="server">
<MasterTableView EditMode="Batch" BatchEditingSettings-EditType="Cell" >
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" CellSelectionMode="MultiCell" />
<ClientEvents OnRowClick="RowSelected" />
</ClientSettings>
</telerik:RadGrid>
</div>
</form>
</body>
</html>
code behind:
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class OnRowSelected : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetValues();
}
private void GetValues()
{
DataTable dtTable = new DataTable();
dtTable.Columns.Add("Sum");
dtTable.Columns.Add("Value1"); dtTable.Columns.Add("Value2");
dtTable.Columns.Add("Value3"); dtTable.Columns.Add("Value4");
DataRow dr = dtTable.NewRow();
dr["Sum"] = "";
dr["Value1"] = "1"; dr["Value2"] = "2";
dr["Value3"] = "3"; dr["Value4"] = "4";
dtTable.Rows.Add(dr);
DataRow drr = dtTable.NewRow();
drr["Sum"] = "";
drr["Value1"] = "5"; drr["Value2"] = "6";
drr["Value3"] = "7"; drr["Value4"] = "8";
dtTable.Rows.Add(drr);
RadGrid1.DataSource = dtTable;
RadGrid1.DataBind();
}
}
| RadGrid grid = new RadGrid(); |
| grid.ID = "radgridExportToExcel"; |
| grid.HeaderStyle.Font.Bold = true; |
| grid.DataSource = dsFileListToDelete.Tables[0].DefaultView; |
| string currentdatetime = DateTime.Now.ToString(); |
| string metadataReportName = string.Format(@"{0}\{1}_Metadata", Server.MapPath(@"~/WCCMetadataReports"), currentdatetime.Replace(" ", "").Replace("/", "").Replace(":", "")); |
| // render the DataGrid control to a file |
| grid.ExportSettings.ExportOnlyData = true; |
| grid.ExportSettings.IgnorePaging = true; |
| grid.ExportSettings.OpenInNewWindow = false; |
| grid.ExportSettings.FileName = metadataReportName; |
| grid.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML; |
| grid.Rebind(); |
| grid.MasterTableView.ExportToExcel(); |
Hi there,
Is there a way to customize the node inspector module of Rad Editor? I need to remove the functionality for CLASSNAME and PROPERTIES button. So all that would be available is width, height, border color/width, tooltip, title, and alignment?
Hi, i have a problem, i see demo http://demos.telerik.com/aspnet-ajax/dock/examples/dockresize/defaultcs.aspx where i see drag and resize dock panel, but i want use code like this
<telerik:RadDockLayout ID="RadDockLayout1" runat="server">
<telerik:RadDockZone ID="RadDockZone1" runat="server" MinHeight="300" Width="300">
<telerik:RadDock ID="RadDock1" runat="server" Title="RadDock1" Width="200px" Resizable="true" EnableDrag="True"
Text="RadDock is placed in a <strong>vertically</strong> oriented RadDockZone. Grab the bottom handle to resize the dock vertically. Horizontal resizing is not allowed." CssClass="higherZIndex">
</telerik:RadDock>
<telerik:RadDock ID="RadDock2" runat="server" Title="RadDock1" Width="200px" Resizable="true" EnableDrag="True"
Text="RadDock is placed in a <strong>vertically</strong> oriented RadDockZone. Grab the bottom handle to resize the dock vertically. Horizontal resizing is not allowed." CssClass="higherZIndex">
</telerik:RadDock>
</telerik:RadDockZone>
</telerik:RadDockLayout>
where user must be have ability for resize docks but can't drag, now user can't resize. What am i doing wrong?