This is a migrated thread and some comments may be shown as answers.

Script error on RadListboxItem contextmenu showing

3 Answers 72 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Nagarajan
Top achievements
Rank 1
Nagarajan asked on 09 Nov 2012, 07:19 AM
Hi,

I have RadListboxitems with context menu, after i selected one listboxitem now trying to invoke context menu for another item throws script error says "Microsoft JScript runtime error: 'this._dragSelector' is null or not an object".  Am I missing any properties?

Listbox
-----------------
<telerik:RadListBox runat="server" Skin="Office2010Blue" EnableDragAndDrop="false" ClientIDMode="Static" ID="Listbox"
                        DataTextField="category" DataValueField="categoryid" OnClientContextMenu="showContextMenu" 
                        AllowAutomaticUpdates="false" AllowDelete="false" AllowReorder="false" AllowTransfer="false" SelectionMode="Single"
                            Width="200px" Height="350px" OnClientSelectedIndexChanged = "Listbox_OnClientSelectedIndexChanged">
</telerik:RadListBox>

Contextmenu
------------------------
<telerik:RadContextMenu ID="Contextmenu" runat="server" Skin="Office2010Blue">
                       <Items>
                           <telerik:RadMenuItem Text="Add"></telerik:RadMenuItem>
                           <telerik:RadMenuItem Text="Edit "></telerik:RadMenuItem>
                           <telerik:RadMenuItem Text="Delete"></telerik:RadMenuItem>
                       </Items>
 </telerik:RadContextMenu>


Thanks,
Nagarajan.

3 Answers, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 13 Nov 2012, 02:23 PM
Hello Nagarajan,

Can you please provide the code used for the OnClientContextMenu and OnClientSelectedIndexChanged
 client-side events. Thus, I can test your scenario locally and determine what is causing the exception that you get.

All the best,
Kate
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nagarajan
Top achievements
Rank 1
answered on 15 Nov 2012, 06:26 AM
Thanks for the reply,

Code in OnClientContextMenu
---------------------------------------------
function showContextMenu(sender, e) {
            if (e.get_item()) {
                var menu = $find("CategoryContextmenu1");
                var rawEvent = e.get_domEvent().rawEvent;
                menu.show(rawEvent);
                e.get_item().select();
                $telerik.cancelRawEvent(rawEvent);
            }
}

Code in OnClientSelectedIndexChanged 
-----------------------------------------------------
 function Category1Listbox_OnClientSelectedIndexChanged(sender, eventArgs) {
       $find("rpanCat2").ajaxRequest(eventArgs.get_item().get_value());
}

.cs code
-----------------
  protected void rpanCat2_PreRender(object sender, EventArgs e)
        {
            if (Request["__EVENTTARGET"] == rpanCat2.ClientID)
            { 
                if (!string.IsNullOrWhiteSpace(Request["__EVENTARGUMENT"]) &&
                    Request["__EVENTARGUMENT"] != "undefined")
                {
                    Listbox.DataSource = GetList();
                    Listbox.DataBind(); 
                }
            }
        }

Note: Once I remove OnClientSelectedIndexChanged  event works fine.

Regards,
Nagarajan.
0
Nagarajan
Top achievements
Rank 1
answered on 16 Nov 2012, 05:53 AM
When we remove ajaxRequest from OnClientSelectedIndexChanged it works fine... Is this a known issue

Tags
ListBox
Asked by
Nagarajan
Top achievements
Rank 1
Answers by
Kate
Telerik team
Nagarajan
Top achievements
Rank 1
Share this question
or