

Hi Team,
We are having issue with yahoo interface after telerik upgrade.
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
RegisterIncludes();
_triggerLink.Text = Text;
if(!string.IsNullOrEmpty(MenuBodyId))
_menuPanel.Attributes.Add("menu-body", MenuBodyId);
var attributes = new List<string> {string.Format("clicktohide:{0}", ClickToHide.ToString().ToLower())};
_attributes.Text = string.Empty;
_attributes.Text += string.Join("|", attributes.ToArray());
_targets.Text = string.Empty;
if(Links != null && Links.Count() > 0)
_targets.Text = string.Join("|", Links.ToArray());
}
private void RegisterIncludes()
{
RegisterJs("utils", "~/include_common/YUI/test.js");
RegisterJs("container_core", "~/common/YUI/core-min.js");
RegisterJs("menu_min", "~/common/YUI/testmenu-min.js");
}
private void RegisterJs(string key, string relativeUrl)
{
if(!Page.ClientScript.IsClientScriptIncludeRegistered(key))
Page.ClientScript.RegisterClientScriptInclude(key, ResolveUrl(relativeUrl));
}I have a web application that dynamically builds its rows and columns. The data type is specified for each row in column 2. As you see in the ASPX code below, I use the OnKeyPress client-side event to try to prevent letters from being entered into numeric fields (R for real, and I for integer).
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<script type="text/javascript">
function OnGridCreated(sender, args) {
// Resize columns to fit data
var grid = sender;
var gridElement = grid.get_element();
// Attach the keydown event
$telerik.$(gridElement).on('keydown', OnKeyDown);
var masterTable = grid.get_masterTableView();
var columns = masterTable.get_columns();
// Resize all Columns
columns.forEach(col => col.resizeToFit());
// Collect the width of all columns
var allColumnsWidth = columns.map(col => col.get_element().offsetWidth);
// Get the Frozen Scroll
var frozenScroll = $telerik.$(gridElement).find('div[id$=_Frozen]').get(0);
var scrollLeftOffset = 0;
var lastWidth = 0;
// Assign function to recalculate scrolling
$telerik.$(grid.GridDataDiv).on('scroll', function (e) {
for (var i = 0; i < columns.length; i++) {
if (!columns[i].get_visible()) {
scrollLeftOffset += allColumnsWidth[i];
lastWidth = allColumnsWidth[i];
}
}
var thisScrollLeft = this.scrollLeft;
this.scrollLeft = 0;
if (thisScrollLeft > 0) {
// To insure the current cell is not on the right edge, add the last column's width
frozenScroll.scrollLeft = thisScrollLeft + scrollLeftOffset + lastWidth;
}
scrollLeftOffset = 0;
})
}
function OnKeyDown(event) {
// Look for TAB
if (event.which == 9) {
var gridElement = event.currentTarget;
var grid = gridElement.control;
var masterTableView = grid.get_masterTableView();
var target = event.target;
var currentCell = $telerik.$(target).closest('td.rgBatchCurrent').get(0);
if (!currentCell) return;
var cellIndex = currentCell.cellIndex;
var numColumns = masterTableView.get_columns().length - 1;
var frozenScroll = $telerik.$(gridElement).find('div[id$=_Frozen]').get(0);
if (!event.shiftKey) {
if (cellIndex == numColumns) {
// Reset scroll position to left edge
frozenScroll.scrollLeft = 0;
}
}
else {
// Reduce the scroll position by the current cell's width
frozenScroll.scrollLeft = frozenScroll.scrollLeft - currentCell.offsetWidth;
}
}
}
function OnKeyPress(sender, args)
{
// What is the key that was pressed
var c = args.get_keyCode();
// What is this row's data type (second column)
var d = args._domEvent.rawEvent.path[3].cells[1].textContent.trim();
var isNumeric = (c >= 48 && c <= 57); // 0 through 9
var isNegative = (c == 45); // hyphen or minus
var isSymbol = (c == 44) || (c == 46); // comma or period
var isModifier = (args._isAltPressed || args._isCtrlPressed || args._isShiftPressed);
console.log(c);
console.log(d);
console.log(isNumeric);
console.log(isNegative);
console.log(isSymbol);
console.log(isModifier);
if (d == 'S') {
// string allows everything
args.set_cancel(false);
} else if (d == 'I') {
// integer allows numbers and minus
var xxx = !((isNumeric || isNegative) && !isSymbol && !isModifier);
console.log(xxx)
args.set_cancel(xxx);
} else if (d == 'R') {
var xxx = !((isNumeric || isNegative || isSymbol) && !isModifier);
console.log(xxx)
// real allows numbers, minus, comma, and decimal
args.set_cancel(xxx);
}
}
</script>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<div>
<telerik:RadGrid ID="RadGrid1" runat="server"
OnNeedDataSource="RadGrid1_NeedDataSource"
AutoGenerateColumns="False">
<ClientSettings AllowKeyboardNavigation="True">
<Scrolling FrozenColumnsCount="2" AllowScroll="True" ScrollHeight="600px" UseStaticHeaders="True"></Scrolling>
<Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting>
<ClientEvents OnGridCreated="OnGridCreated" OnKeyPress="OnKeyPress" />
<Resizing AllowColumnResize="True" AllowResizeToFit="True" ClipCellContentOnResize="False" />
</ClientSettings>
<AlternatingItemStyle Wrap="True" BackColor="Gainsboro"></AlternatingItemStyle>
<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="PeopleID" EditMode="Batch" TableLayout="Fixed">
<BatchEditingSettings EditType="Row" />
<Columns>
</Columns>
<CommandItemSettings ShowAddNewRecordButton="False" />
</MasterTableView>
<HeaderStyle VerticalAlign="Bottom" Font-Bold="True" BackColor="DarkSeaGreen" Wrap="False"></HeaderStyle>
<ActiveItemStyle Wrap="True"></ActiveItemStyle>
</telerik:RadGrid>
</div>
</form>
</body>
</html>
C#:
using System;
using Telerik.Web.UI;
using System.Data;
public partial class Default : System.Web.UI.Page
{
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
DataTable dt = new DataTable();
DataRow dr;
int rowsNum = 130;
string[][] colsInfo = {
new string[] { "PeopleID", "number" },
new string[] { "Type", "string" },
new string[] { "Custom1", "string" },
new string[] { "Custom2", "string" },
new string[] { "Custom3", "string" },
new string[] { "Custom4", "string" },
new string[] { "Custom5", "string" },
new string[] { "Custom6", "string" },
new string[] { "Custom7", "string" },
new string[] { "Custom8", "string" },
new string[] { "Custom9", "string" },
new string[] { "Custom10", "string" },
new string[] { "Custom11", "string" },
new string[] { "Custom12", "string" },
new string[] { "Custom13", "string" },
new string[] { "Custom14", "string" },
new string[] { "Custom15", "string" },
new string[] { "Custom16", "string" },
new string[] { "Custom17", "string" },
new string[] { "Custom18", "string" },
new string[] { "Custom19", "string" },
new string[] { "Custom20", "string" },
};
for (int i = 0; i < colsInfo.Length; i++)
{
GridBoundColumn newColumn = new GridBoundColumn();
newColumn.DataField = colsInfo[i][0];
newColumn.UniqueName = colsInfo[i][0];
newColumn.HeaderText = "*" + colsInfo[i][0] + "*";
RadGrid1.MasterTableView.Columns.Add(newColumn);
switch (colsInfo[i][1])
{
case "string":
dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(String)));
break;
case "number":
dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(Int32)));
break;
case "date":
dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(DateTime)));
break;
case "bool":
dt.Columns.Add(new DataColumn(colsInfo[i][0], typeof(Boolean)));
break;
default:
break;
}
}
for (int j = 1; j <= rowsNum; j++)
{
dr = dt.NewRow();
for (int k = 0; k < colsInfo.Length; k++)
{
switch (colsInfo[k][1])
{
case "string":
string x = "";
if (k == 1)
{
if ((j % 3) == 0)
x = "S";
else if ((j % 2) == 0)
x = "I";
else
x = "R";
}
dr[colsInfo[k][0]] = x;
break;
case "number":
dr[colsInfo[k][0]] = j;
break;
case "date":
dr[colsInfo[k][0]] = DateTime.Now;
break;
case "bool":
dr[colsInfo[k][0]] = j % 2 == 1 ? true : false;
break;
default:
break;
}
}
dt.Rows.Add(dr);
}
(sender as RadGrid).DataSource = dt;
}
}
If I type a letter into any cell of a row with an "I" or "R" in the second column, I want it to ignore that character. The console.log() calls confirm that the variables in my JavaScript function are what I expect them to be, but the args.set_cancel(true) calls are not doing what I expect.
What do I need to do to get this character validation working?
What improvements/optimizations can be made to the OnKeyPress() function?

Hi Team,
I have an issue with OnClientClose and OnClientShow.
Its not firing when we call it from js file as mentioned in OnClientClose and OnClientShow.
Can anyone help me how to resolve this issue?
<telerik:RadWindowManager
id="WindowManager" runat="server"
OnClientClose = "Test.Extensions.Search.queryBuilderDialog.onSubmit" (Replaced ClientCallBackFunction as OnClientClose)
OnClientShow = "Test.Extensions.Search.queryBuilderDialog.onShow">
<windows>
<telerik:RadWindow id="TestWindow"
Left="250px"
Modal="true"
Runat="server"
Behaviors="Move,Resize,Close">
</telerik:RadWindow>
</windows>
</telerik:RadWindowManager>Code of a Querydebug.JS file:
Test.Extensions.Search.BuildQueryDialog.prototype = {
//Properties
queryBuilderDialog: null,
this.queryBuilderDialog = new Test.Extensions.Search.BuildQueryDialog();
radWindow: null,
windowUrl: "",
//Methods
show: function (fieldId, isEdit) {
var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft,
scrollY = document.documentElement.scrollTop || document.body.scrollTop,
viewPortWidth = $D.getClientWidth(),
viewPortHeight = $D.getClientHeight(),
elementWidth = 600,
elementHeight = 400,
x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX,
y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
this.radWindow = Test.Utilities.WindowUtil.getRADWindow("TestWindow");
if (this.windowUrl === "")
this.windowUrl = this.radWindow.GetUrl();
var separator = (this.windowUrl.indexOf("?") == -1) ? "?" : "&";
var url = this.windowUrl + separator + "id=" + fieldId + "&isedit=" + isEdit;
this.radWindow.SetUrl(url);
this.radWindow.Show();
this.radWindow.MoveTo(x, y);
this.radWindow.SetSize(elementWidth, elementHeight);
},
//Event Handlers
onShow: function (radWindow) {
var currentCondition = Test.Extensions.Search.queryBuilder.getCurrentCondition();
//Set the argument object to the radWindow
radWindow.Argument = { conditionXml: $XML.SerializeXmlNode(currentCondition.toXml()) };
},
onClose: function (radWindow) { },
onSubmit: function (radWindow, returnValue) {
if (returnValue && returnValue.conditionXml) {
var currentCondition = Test.Extensions.Search.queryBuilder.getCurrentCondition();
currentCondition.fromXml(returnValue.conditionXml);
}
}
};Hello,
i am trying to read the values of columns on button click in a telerik:GridTemplateColumn but seems not working
<telerik:RadGrid RenderMode="Lightweight" runat="server" AutoGenerateColumns="False" ID="RadGrid1"
AllowFilteringByColumn="false" Width="100%" BorderWidth="0px" GridLines="Both"
AlternatingItemStyle-HorizontalAlign="Center" AllowSorting="false">
<MasterTableView TableLayout="Fixed" HeaderStyle-Font-Bold="true" ClientDataKeyNames="RepCRD" DataKeyNames="RepCRD" >
<Columns>
<telerik:GridBoundColumn DataField="RepCRD" Visible="false" HeaderText="RepCRD" UniqueName="RepCRD" ReadOnly="True" />
<telerik:GridTemplateColumn HeaderText="" UniqueName="AddAdv" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" AllowSorting="false" AllowFiltering="false">
<ItemTemplate>
<telerik:RadButton ID="btnAddAdv" CommandName="AddAdv" OnClick="btnAddAdv_Click" RenderMode="Lightweight" runat="server" AutoPostBack="true" Text="Add Advisor" />
<asp:Label ID="RepCRDlbl" Visible="false" Text='<%# Eval("RepCRD")%>' runat="server"></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridHyperLinkColumn HeaderText="CRD#" DataTextFormatString="{0}" DataNavigateUrlFields="RepCRD" Target="_blank" ItemStyle-HorizontalAlign="Center" UniqueName="RepCRD" DataTextField="RepCRD" />
<telerik:GridBoundColumn DataField="FullName" HeaderText="Name" SortExpression="FullName" UniqueName="FullName" ItemStyle-HorizontalAlign="Center" />
<telerik:GridHyperLinkColumn HeaderText="Broker/Dealer Firm CRD#" DataTextFormatString="{0}" DataNavigateUrlFields="BDFirmCRD" Target="_blank" ItemStyle-HorizontalAlign="Center" UniqueName="BDFirmCRD" DataTextField="BDFirmCRD" />
<telerik:GridBoundColumn DataField="BrokerDealerName" HeaderText="Broker/Dealer Name" SortExpression="BrokerDealerName" UniqueName="BrokerDealerName" ItemStyle-HorizontalAlign="Center" />
<telerik:GridTemplateColumn HeaderText="" UniqueName="AddFirm1" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" AllowSorting="false" AllowFiltering="false">
<ItemTemplate>
<telerik:RadButton ID="btnAddFirm1" CommandName="AddFirm1" OnClick="btnAddFirm1_Click" RenderMode="Lightweight" runat="server" AutoPostBack="true" Text="Add Firm" />
<asp:hiddenfield ID="BDFirmCRDlbl" Value='<%# Eval("BDFirmCRD")%>' runat="server"></asp:hiddenfield>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>On Click of Button btnAddFirm1 it should read the BDFirmCRDlbl value like here
Protected Sub btnAddFirm1_Click(sender As Object, e As EventArgs)
Dim Button As RadButton = CType(sender, RadButton)
Dim sBDFirmCRDlbl As String
For Each item As GridDataItem In RadGrid1.MasterTableView.Items
Dim strBDFirmCRD As String = item("BDFirmCRD").Text
sBDFirmCRDlbl = (TryCast(item.FindControl("BDFirmCRDlbl"), HiddenField)).Value
Next
End Subthe problem that it is only returning the last item in the grid and not the clicked value
Thanks

Hello,
I need a client-side solution that conditionally will not change the pager combo value. I found an old thread here with some suggested client code at the bottom. Basically, the pager's combo box selectedIndexChanging event is handled, and under given condition is canceled. However, what I'm finding is that when not cancelled, the event is called twice. Why is that, and how do I prevent? Below is a simple example that demonstrates the issue.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta charset="utf-8"/>
<title></title>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function pageLoad(sender, eventArgs) {
}
function onCommand(sender, args) {
args.set_cancel(true);
var lsCommand = args.get_commandName();
if (lsCommand == "PageSize") {
console.log('Got PageSize Command');
}
}
function onMasterTableViewCreated(sender, args) {
console.log('Creating selectedIndexChanging Handler');
var pageSizeCombo = $telerik.findControl(sender.get_element(), "PageSizeComboBox");
if (pageSizeCombo) {
pageSizeCombo.add_selectedIndexChanging(function (sender, args) {
//this method will fire before the combo changes the
//page size in the grid pager. You can cancel this event
// If condition is met, cancel
if (args.get_item().get_value() == "20") {
args.set_cancel(true);
console.log('Page Size change cancelled')
}
else {
console.log('Page Size change allowed');
}
});
}
}
</script>
</telerik:RadCodeBlock>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" />
<telerik:RadSkinManager ID="RadSkinManager1" runat="server" Skin="Default" ShowChooser="false" />
<telerik:RadGrid ID="RadGrid1" runat="server"
EnableViewState="false"
AutoGenerateColumns="false"
AllowPaging="false"
AllowSorting="true"
Width="100%"
Height="150px"
>
<MasterTableView
TableLayout="Fixed"
AllowNaturalSort="false"
ClientDataKeyNames="Name"
AllowPaging="true"
EnableViewState="false"
>
<Columns>
<telerik:GridBoundColumn DataField="Name" UniqueName="Name" DataType="System.String" HeaderText="Name" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn DataField="Count" UniqueName="Count" DataType="System.Int32" HeaderText="Count" HeaderStyle-Width="150px" />
</Columns>
<NoRecordsTemplate>
<table style="height: 120px; width:100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">
There are no files matching the search criteria.
</td>
</tr>
</table>
</NoRecordsTemplate>
<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" PageSizes="10,20,50,100" />
</MasterTableView>
<ClientSettings>
<ClientEvents
OnCommand="onCommand"
OnMasterTableViewCreated="onMasterTableViewCreated"
/>
<Selecting AllowRowSelect="true" />
<Scrolling AllowScroll="true" UseStaticHeaders="true" />
<DataBinding ShowEmptyRowsOnLoad="false" />
</ClientSettings>
<SortingSettings EnableSkinSortStyles="false" />
</telerik:RadGrid>
</form>
</body>
</html>
public partial class Test2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Name", System.Type.GetType("System.String"));
dt.Columns.Add("Count", System.Type.GetType("System.Int32"));
DataRow dr = dt.NewRow();
dr["Name"] = "Name1";
dr["Count"] = 25;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["Name"] = "Name2";
dr["Count"] = 18;
dt.Rows.Add(dr);
RadGrid1.DataSource = dt;
RadGrid1.DataBind();
RadGrid1.MasterTableView.PageSize = 20;
}
}
Thanks,
Dave
When I use the Rad radio button and checkboxes... something is messing up the alignments. I have reviewed my css, in page style changes and inspected the page in chrome and edge and I cannot find what is causing this (looks like all the applied styles are coming from Telerik.Web.
Any thoughts on where to fix this?

RadImageEditor maybe one of the worst thought out controls you have in your control suite. It could have been easy...if you consulted programmers who actually have to use this. Rant over, now lets get to the reson why we're here.
The source of my images are stored in a SQL DB. After jumping thru spiked hoops...I figured out how to save and load the images in the RadImageEditor. For the record, way harder than it needed to be. My problem is after I make changes to the image, ie maybe a resize, there is no easy way to to get the altered image. I thought the following code would do the trick:
Dim img As EditableImage = RadImageEditor1.GetEditableImage
boy was I wrong. I've seen the posts about CanvasMode...doesn't change the outcome. I've tried all 3 settings. I've tried changing the property in the aspx page. I've tried changing the property in the code behind. Result is always the unaltered image. Would it have killed you to have a GetChangedImage option?
I'm controlling the events in the code behind. I'm not using client events. I want to press a button and in the code behind/server code...save the data on my screen to a database and I would like to know how to include the altered image in that save? I'm not using any of the buttons on the RadImageEditor.
I would appreciate the code in VB and I would appreciate an actual example not a link to some demo because I've already been thru them with a fine tooth comb.
Thanks in advance.

The project I am working on, uses Grids and for some reason it has extended (customized styling and other functionalites) RadGrids with extended Column as well (see an extract of the class below).
When I use the functionality exportToExcel in a telerik RadGrid, it works like I want but on the extended RadGrids it doesn't export the grid to a file but it replaces the grid on the UI. Page (I have attached two images, one with the exportToExcel button and the other with the "exported" table) . Do I also need to write a customized ExportToExcel function? or how could I approach this issue?
Thanks in advance.
public class DefaultGridBoundColumn:GridBoundColumn
{
public int ColumnWidth { get; set; }
public DefaultGridBoundColumn()
{
AllowFiltering = false;
ColumnWidth = -1;
}
public override void Initialize()
{
if (ColumnWidth >= 0)
{
base.HeaderStyle.CssClass = (base.HeaderStyle.CssClass + " col-md-" + ColumnWidth).Trim();
base.ItemStyle.CssClass = (base.ItemStyle.CssClass+ " col-md-" + ColumnWidth).Trim();
}
base.Initialize();
}
}
}