
Hello Team,
Recently I upgraded ,telerik control(2015, 2, 623, 40) to make compatible for IE 11 but after upgrading the telerik control ,getting unexpected behavior for control
I am using telerik RadListBox along with RadContextMenu ,also RadListBox having postback on selection of the record .But when I do right click to open the contextmenu then postback event getting fire and not able to select the context menu.
I will appreciate ,if I get the early response , because it urgent need for business
here is code sample
-----------------------------------------------------------------------------------------------------------------------
HTML
<telerik:RadListBox ID="rdListDocumentTypes" Skin="Outlook" Height="150px" Width="305px"
AllowReorder="true" AllowDelete="true" OnClientSelectedIndexChanged="DirtyTrackListBox"
OnClientContextMenu="showContextMenuOnDocumentType" SelectionMode="Single" AutoPostBack="true"
runat="server">
<ButtonSettings ShowDelete="false" ShowReorder="false" />
</telerik:RadListBox>
<telerik:RadContextMenu ID="contextMenuDocumentTypes" runat="server" OnClientItemClicking="OnClientDocumentTypeDelete"
Skin="Outlook" OnClientItemClicked="onItemClickedOnDocumentType" Style="top: 298px;
left: 12px">
<Items>
<telerik:RadMenuItem Text="Delete" Value="Delete" />
</Items>
</telerik:RadContextMenu>
------------------------------------------------------------------------
JavaScript
function OnClientDocumentTypeDelete(sender, eventArgs)
{
if (eventArgs.get_item().get_value() == "Delete")
{
if (!confirm('Are you sure you want to delete this record?'))
{
eventArgs.set_cancel(true);
return false;
}
ResetDirty(sender._element);
return true;
}
return false;
}
function showContextMenuOnDocumentType(sender, e)
{
var menu = $find("<%=contextMenuDocumentTypes.ClientID %>");
if (menu == null) return;
var rawEvent = e.get_domEvent().rawEvent;
if (e.get_item() != null)
{
menu.show(rawEvent);
e.get_item().select();
}
$telerik.cancelRawEvent(rawEvent);
}
function onItemClickedOnDocumentType(sender, e)
{
var listBox = $find("<%=rdListDocumentTypes.ClientID %>");
var index = listBox._selectedIndices[0];
var id = listBox._itemData[index].value;
document.getElementById("<%=hdfSelectedDocumentType.ClientID %>").value = id;
}
12 Answers, 1 is accepted
The postback is caused by the posted below line of code in your showContextMenuOnDocumentType handler, which selects the item you have right-clicked on and since the RadListBox' AutoPostBack property is set to "true" the item selection posts the page:
e.get_item().select();
Regards,
Ivan Danchev
Telerik

Hello Ivan,
Its true , but unexpected result ,which is coming from Listbox, was not earlier , it came when I upgraded the Telerik control for IE 11.
I can commented out the line , but my application is in the production ,so I cant make the such changes.
Is there any way ,to get the same result as it was earlier without commented out the line, with upgraded telerik control on IE 11
Another way to enable Item selection and context menu showing on right click is to set RadListBox' AutoPostBack property to "false".
Which version were you using before upgrading to 2015, 2, 623, 40? We would like to check how its behavior in this scenario differs from the one of the version you are currently using.
Regards,
Ivan Danchev
Telerik

Hello Ivan,
Thanks for your response,earlier I was using Telerik 2013.2.717.40, also I cannot set the AutoPostBack property to false because on the selection of record data gets populate.
Thanks
Afroz Khan
Thank you for specifying the old version you were using.
The tests showed that the behavior of the RadListBox was different in 2013.2.717.40, however since 2014 Q1 the selection of an item does cause a postback just like in the current version of the controls. This is the expected behavior and it is explained in the SelectedIndexChanged article.
I am afraid there is no way to avoid the postback with the AutoPostBack property set to "true", unless you cancel the SelectedIndexChanging event, but doing so will prevent the item selection.
Regards,
Ivan Danchev
Telerik


Hello Ivan,
Could you please help to get value from Listbox using ContextMenu if I do commented out below line?
e.get_item().select();
Because if I remove the above line then I will not be able to get the value
Are you trying to get the value from the ListBox item you right click on? This item is accessible in the showContextMenuOnDocumentType handler through the event arguments parameter's get_item() method so you can get its value like this: e.get_item().get_value().
Regards,
Ivan Danchev
Telerik

Thanks Ivan, I am able to get the Id on context menu ,but still I am really surprise, how latest version of telerik control changing their functional behavior on running application?
This change was introduced in order to make the controls behavior consistent. The behavior of the ListBox control previously to the change that occurred in 2014 Q1 was not correct, so this change can even be considered as a fix, because it leads to expected behavior when the AutoPostBack property is set to "true".
Regards,
Ivan Danchev
Telerik

You are welcome. Please let us know in case you encounter any issues with the ListBox or another of our controls.
Regards,
Ivan Danchev
Telerik