RadListbox : Undefined is null or not an object onclick when no items

2 posts, 1 answers
  1. rei
    rei avatar
    12 posts
    Member since:
    Jul 2009

    Posted 03 Dec 2009 Link to this post

    Hi,

    I have a listbox  that I am populating client side from a list of items that users entered. Initially there are no listbox items, but I set the height of the listbox to 200px. When I click inside the listbox when there are still no items , it displays a  javascript error 'undefined' is null or not an object.  I believe it happens on the _activateItem client side event  of the listbox, but Im not sure how to disable it when there are no items in the list.

    Is there a way to trap the _activeitem event on client side or disable it when the list of items = 0 ?

    Thanks,
    rei
  2. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 04 Dec 2009 Link to this post

    Hello rei,

    This is a known issue with the RadListBox. We have already fixed it, you can check up on the latest internal build. If you cannot update to the latest internal you can use the following work around, please paste it right after your script manager declaration:

    Telerik.Web.UI.RadListBox.prototype._onFocus = function(e) {
              if (this._activeItem) {
                  $(this._activeItem.get_element()).addClass("rlbActive");
                  return;
              }
      
              var item = this.get_selectedItem();
              if (item) {
                  this._activateItem(item, true);
                  return;
              }
      
              item = this._getFirstVisibleItem()
              if (item) {
                  this._activateItem(item);
                  return;
              }
          }


    All the best,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top